2
votes

How can I get all the values for keys having regex in hbase shell

for instance, I have something like Row key Column 1,2017-05-06 't1:5' 1,2017-05-07 't2:6'

Now I want something like all the column families for Row key '1,*' where * is denoted by all days. Is it possible?

2

2 Answers

4
votes

Try this if you want to use regex.

scan ‘myTable’, {FILTER => "RowFilter(=, 'regexstring:^1,.*’)”}

It is better to use prefix filter given in the previous answer when you know the pattern is at the start of rowkey.

A more complicated regex like following can use the Rowfilter with regexstring in the hbase shell.

scan 'myTable', { FILTER => "RowFilter(=, 'regexstring:.*-.+[d]{2}1-.*')" }

This will match any rowkey with pattern "dd1-" with a dash and one character before it.

You can use some online regex tester like https://regex101.com/ for trying out your regex.

3
votes

You can try something like this :

scan ‘myTable’, {FILTER => “(PrefixFilter (‘1,’)”}

Source : HBase documentation suggestion https://learnhbase.wordpress.com/2013/03/02/hbase-shell-commands/