Reputation: 345
I wanna select some rows from hbase table, how to set multifilters? It seems that AND
doesn't work.
I have tried two ways.
scan 'hbase_table', { FILTER => "(RowFilter(=, 'regexstring:39$') AND SingleColumnValueFilter ('binary:family','binary:qualifier', '=', 'value')" }
or
scan 'hbase_table', {LIMIT => 10, FILTER => "(RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'), RegexStringComparator.new("39$")) AND SingleColumnValueFilter.new(Bytes.toBytes('family'), Bytes.toBytes('qualifier'), CompareFilter::CompareOp.valueOf('EQUAL'), Bytes.toBytes('value')))", COLUMNS => 'family:qualifier'}
many thanks
Upvotes: 5
Views: 9133
Reputation: 556
Using only SingleColumnValueFilter
scan 'table', {FILTER => "SingleColumnValueFilter
('columnfamily', 'columnname', =, 'binary:value', true, false)
AND SingleColumnValueFilter('columnfamily', 'columnname', =, 'binary:value', true, false)"}
Replace following fields,
table - hbase table name ex: hbaseTemp
columnfamily - hbase column family name ex: s
columnname - hbase column name ex: id
value - hbase field value ex: 12343
Docx for SingleColumnValueFilter: https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.html
Upvotes: 1
Reputation: 101
This question was asked long back, but just in case it helps someone...
I have tried combining prefixfilter and SingleColumnValueFilter like below and it works as expected:
scan 'dbtest:table1', {FILTER => "(PrefixFilter ('abc') AND SingleColumnValueFilter('cf','age',>=, 'binary:10',true,false)"}
Here
This link should help understand the filters better
Upvotes: 1