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

2.9k Views Asked by At

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?

1

There are 1 best solutions below

0
Averman On BEST ANSWER

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);