1

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 Answers1

2

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);
Martin Serrano
  • 3,727
  • 1
  • 35
  • 48
Anirudh
  • 150
  • 3
  • sorry for the confusion describe of my question. And I explain it more explicitly. My rowkey is type_a|type_b|type_c, and I want to get row specified by type_b part. How can I achieve this? Or can I achieve this in HBase? Thanks a lot for your anwser. – Sparrow Jack Feb 18 '16 at 02:13