user3570620
user3570620

Reputation: 359

How to find all rows in HBase table that have a specific value in a specific column

In HBase table, I have a column family addr with 3 columns: addr:city, addr:state, addr:zip. I want to find all rows with city = Chicago. any idea which filter to use? What is the java syntax?

Upvotes: 0

Views: 2936

Answers (1)

Averman
Averman

Reputation: 441

You can use single column value filter to set whether a row is returned or not based on value in a single column. Example:

    Filter filter = new SingleColumnValueFilter(Bytes.toBytes("addr"),
            Bytes.toBytes("city"), CompareOp.EQUAL, Bytes.toBytes("Chicago"));
    scan.setFilter(filter);
    ResultScanner rs = table.getScanner(scan);

Upvotes: 6

Related Questions