How to scan HBase with specific part of rowkey?

1k views Asked by At

For example, rowkey is designed as aabbbbcccc, the bbbb part is the specific part which is used to index the record. How can I search HBase table with the bbbb part?

1

There are 1 answers

1
Anirudh On

You can use the RowFilter with the SubstringComparator on Scan object to fetch matching records. Note this will require a full scan of all the data.

Scan scan = new Scan();

scan.setFilter(new RowFilter(CompareOp.EQUAL, new SubstringComparator("bbbb")));

scan.addFamily(Bytes.toBytes("columnFamily"));
ResultScanner scanner = table.getScanner(scan);