javafilterhbasedatabase-scan

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?


Solution

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