Wednesday, June 25, 2014

Filter query in HBase Shell



For a quick reference, to filter a column in HBase Shell, we can run the command as below,

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
scan 'table_name', {FILTER => SingleColumnValueFilter.new(Bytes.toBytes('family'),Bytes.toBytes('qualifier'),CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('filter_value')), COLUMNS => ['family:qualifier']}

Hope this helps.
Cheers.

No comments :