2

I have an HBase table, person. I'm using ColumnPrefixFilter and SingleColumnValueFilter to fetch details from HBase table

For suppose, I have entries like below-

ROW_KEY     COLUMN+CELL
p1          column='attr:id',value=p1_03
p1          column='details:name_1',value=xyz
p2          column='attr:id',value=p2_04
p2          column='details:name_2',value=xyz

I need to fetch the row_key where name is xyz and id is p1_03. Tried the below query but it results in both row keys.

scan 'person', {FILTER=>"SingleColumnValueFilter('attr','id',=,'binary:p1_03') AND (ColumnPrefixFilter('name') AND ValueFilter(=,'xyz'))"}

Output:

ROW         COLUMN+CELL
p1          column='details:name_1',value=xyz
p2          column='details:name_2',value=xyz

I need to get only one row key p1

Dinesh
  • 1,135
  • 2
  • 15
  • 22
  • What if you just apply the `SingleColumnValueFilter`? – Ben Watson Mar 05 '19 at 10:12
  • @BenWatson Column **name** is auto-incremental, meaning, for row_key **p1** we can have many columns name_1, name_2...name_n, I do not know where **xyz** is. So, I opted for ColumnPrefixFilter – Dinesh Mar 05 '19 at 12:02
  • My point is: does each filter individually do what you expect it to? Break down your problem into smaller problems and see where the error actually is. – Ben Watson Mar 05 '19 at 12:41

1 Answers1

1

You can use SingleColumnValueFilter with AND/OR conditions.

Here since you use different column families, hence use following:

scan 'person', {FILTER=>"SingleColumnValueFilter('attr','id',=,'binary:p1_03') AND  SingleColumnValueFilter('details','name*',=,'binary:xyz')"}
Nishu Tayal
  • 20,106
  • 8
  • 49
  • 101