Search code examples
hbasequalifiers

Apply multiple filters on same column qualifier


In my project,i have a condition where i have to apply two SingleColumnValue filters on same column qualifier. The two filters are to check if the column qualifier contains the value 'A' or the value 'B'. But, the filter doesn't seems to be working.

FilterList filterList = new FilterList(Operator.MUST_PASS_ONE);

SingleColumnValueFilter filter2 = new SingleColumnValueFilter(Bytes.toBytes("data"),               Bytes.toBytes("type"),CompareOp.EQUAL,Bytes.toBytes("A"));
filter2.setFilterIfMissing(true);
filterList.addFilter(filter2);

SingleColumnValueFilter filter1 = new SingleColumnValueFilter(Bytes.toBytes("data"), Bytes.toBytes("type"), CompareOp.EQUAL,  Bytes.toBytes("B"));    filter1.setFilterIfMissing(true);
filterList.addFilter(filter1);

Is there any mistake in doing so? Is this possible, applying two filters on same qualifer? Are there any alternate solutions?

Thanks in advance.


Solution

  • A good way to solve the problem discussed above is to use RegexStringComparator.

    Create a RegexStringComparator with the needed matches and use it with SingleColumnValueFilter.