Scan table with multiple rowkey filter in hbase

9.3k views Asked by At

I have tried with single row-key ,its working fine but i am unable to fetch multiple row-key scan.

scan 'LPV',{FILTER =>"(PrefixFilter('174','194')"}

getting error,find Filter to support scan multiple row key ranges but didnt find is it possible or not ? I want to fetch multiple records based on multiple row-keys. Any help,Thanks.

2

There are 2 answers

0
Arnon Rotem-Gal-Oz On BEST ANSWER

You just need to OR two PrefixFilters as in

scan 'LPV',{FILTER =>"(PrefixFilter('174') OR PrefixFilter('194')"}
0
ozhang On

I am not sure there is a solution in Hbase shell for multiple prefix filter. But you can write a script to do multiple prefixfilter one by one. for example put your key prefixes to a file a1.txt line by line;

a1.txt
-------
pref1
pref2
pref3

then run a script like (i am not good at shell scripting. you can do better)

cat a1.txt | while read LINE; do echo "scan 'LPV',{FILTER=>\"PrefixFilter('$LINE')\"} " | hbase shell;done