user3019299
user3019299

Reputation: 199

HBase Shell query based on RowKey postfix

If I have the following row keys in HBase:

abc_DFS_20
sjd_eir_21
skd_err_22
...
..
sdf_rie_100

For now I want to use HBase Shell to query all the rowkeys which *_ * _number from 30 - 40, so something like

scan 'table', {STARTROW => '*_*_30', ENDROW => '*_*_40'}

Acutally the above query doesn't work. Could anyone give me an idea to achieve this ?

Upvotes: 2

Views: 1351

Answers (1)

Rubén Moraleda
Rubén Moraleda

Reputation: 3067

Talked about it multiple times here, wildcards are not supported, only prefixes can be used as start & stop rows. You have a few options, each one with its own pros & cons (sorted by less complexity/overhead):

  1. Store the value on a column and perform a table scan (no prefix) with a SingleColumnValue filter (server-side full table scan required).
  2. FuzzyRowFilter + SingleColumnValue filter or a Custom filter so rows that don't match with your pattern can be skipped (server-side full table scan required but it will fast forward faster).
  3. Automatic secondary-indexes through a coprocessor (not natively supported).
  4. Manually maintain or dual/write to a secondary-index table (realtime fast) in which the rowkey is your prefix (ie: 20_DFS_abc, 21_sjd_eir ...)

You can find more info here.

Upvotes: 2

Related Questions