Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:45:58+00:00 2026-06-14T12:45:58+00:00

we would like to filter a scan on a HBase table with two QualifierFilters.

  • 0

we would like to filter a scan on a HBase table with two QualifierFilters.
Means we would like to only get the rows of the table which do have a certain column ‘col_A’ AND (!) a certain other column ‘col_B’.

Our current approach looks like this:

FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
Filter filter1 = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator("col_A".getBytes()));
filterList.addFilter(filter1);
Filter filter2 = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator("col_B".getBytes()));
filterList.addFilter(filter2);

Scan scan = new Scan();
scan.setFilter(filterList);
... 

The ResultScanner does not return any results from this scan although there are several rows in the HBase table which do have both columns ‘col_A’ and ‘col_B’.

If we only apply filter1 to the scan everything works fine an we do get all the rows which have ‘col_A’.
If we only apply filter2 to the scan it is the same. We do get all rows which have ‘col_B’.

Only if we combine these two filters we do not get any results.

What would be the right way to get only the rows from the table which do have col_A AND col_B?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:45:59+00:00Added an answer on June 14, 2026 at 12:45 pm

    You can achieve this by defining the following filters:

    List<Filter> filters = new ArrayList<Filter>(2);
    byte[] colfam = Bytes.toBytes("c");
    byte[] fakeValue = Bytes.toBytes("DOESNOTEXIST");
    byte[] colA = Bytes.toBytes("col_A");
    byte[] colB = Bytes.toBytes("col_B");
    
    SingleColumnValueFilter filter1 = 
        new SingleColumnValueFilter(colfam, colA , CompareOp.NOT_EQUAL, fakeValue);  
    filter1.setFilterIfMissing(true);
    filters.add(filter1);
    
    SingleColumnValueFilter filter2 = 
        new SingleColumnValueFilter(colfam, colB, CompareOp.NOT_EQUAL, fakeValue);          
    filter2.setFilterIfMissing(true);
    filters.add(filter2);
    
    FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL, filters);
    Scan scan = new Scan();
    scan.setFilter(filterList);
    

    The idea here is to define one SingleColumnValueFilter per column you are looking for, each with a fake value and a CompareOp.NOT_EQUAL operator. I.e:
    such a SingleColumnValueFilter will return all columns for a given name.

    Source: http://mapredit.blogspot.com/2012/05/using-filters-in-hbase-to-match-two.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to filter certain fields in my database which are Null, 0,
I would like to filter return values of methods which have a @Filter annotation
I have a List. I would like to filter through all the rows in
Hello I have a datatable that I would like to filter with a single
I have a CSV file and I would like to filter all the lines
I have set of 6 elements and I would like to filter by every
I have a TreeMap resMap new TreeMap<String, Map<String, String>>(); I would like to filter
I have a grouped query, and would like to filter it based on count(*)
I would like to filter some rows in a JTable but all the stuff
I have a scenario where I would like to filter some entity sets at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.