How to scan for a particular column value in hbase

2019-08-02 03:07发布

问题:

I am new to using hbase. I have multiple columns which have attributes

How do I search for a particular attribute.

how do I use the scan command in this case?

scan 'table_name' gives all the records.

回答1:

you can use,

scan 'tablename' , {COLUMNS => 'cfamily:cqualifier'}

You can scan multiple columns at a same time using,

scan 'tablename' , {COLUMNS => ['cf1:cq1' , 'cf2:cq2']}



回答2:

Though it is a very old question, But I feel to update this as this would help others to get the answer.

Me too a very beginners of Hadoop-Hbase and I was searching for this answer and found below command that will fetch the values:

Cammand Name: get
Cammand Details: Get row or cell contents; pass table name, row, and optionally a dictionary of column(s), timestamp and versions.
Examples:

hbase> get 'table1', 'row1'  --- this will show all column values for row1 of table1

hbase> get 'table1', 'row1', {COLUMN => 'col1'}  --- this will show value of column col1 of row1 of table1.

Below URL is very helpful for all other Hbase commands.

http://hbase.apache.org/book.html#shell

Thanks.



回答3:

It seems from your example that you are talking about using the hbase shell In this case you can write "help scan" and it will explain how to use that command with examples such as

scan 't1', {FILTER => org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}

You can also see that explanation here.

Note that hbase doesn't have indexes on qualifiers so a scan that does not relay on the key is not very efficient. The usual way to go is to keep in mind that the key is lexicographically ordered and make things you want to search by part of the key. and scan by partial key. You can then further filter by qualifiers but the number of records filtered will be smaller so it would work better. If you are using filters a lot also consider setting the columnfamily with bloom filters



标签: hbase