Rushi Pradhan
Rushi Pradhan

Reputation: 21

How do I query based on column in Hbase?

Example table below. I would like to search all the records by last name . How do I query this in Hbase?

Key First Name  Last Name   Sport
1   John    Smith   Baseball
2   Wayne   Smith   Baseball
3   Robert  Reynolds    Basketball
4   Mark    Thompson    Basketball

Note: Here my row id is “Key” column.

Upvotes: 0

Views: 85

Answers (1)

Abhishek Kumar
Abhishek Kumar

Reputation: 292

HBase doesn't support secondary indexes.So,technically,you can't query on any other column accept the key. However,you can use filters,for example,

  scan 'table', { FILTER => SingleColumnValueFilter.new(Bytes.toBytes('columnFamily'),
  Bytes.toBytes('LastName'), CompareFilter::CompareOp.valueOf('EQUAL'),
  BinaryComparator.new(Bytes.toBytes('Smith')))}

But that is inefficient as this does not reduce server-side IO,becuse whole scan is done and results are then filtered out.However,it does reduce network bandwidth and reduces the amount of data the client needs to process.

Upvotes: 1

Related Questions