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?
Asked
Active
Viewed 1,012 times
1
-
what do you mean `bbbb` is used to index the record? – Martin Serrano Feb 17 '16 at 13:49
-
My rowkey is composed as type_a|type_b|type_c. And bbbb is type_b part. Thanks a lot! – Sparrow Jack Feb 18 '16 at 02:14
1 Answers
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