Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception for POST mode facets if facet_filter accepts no documents #3479

Closed
ccw-morris opened this Issue Aug 10, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@ccw-morris
Copy link

ccw-morris commented Aug 10, 2013

elasticsearch 0.90.3
org.elasticsearch.search.facet.FacetExecutor$Post$Filtered, line 66

for (int i = 0; i < docSets.size(); i++) {
  ContextDocIdSet entry = docSets.get(i);
  DocIdSet filteredSet = filter.getDocIdSet(entry.context, null);
  filteredEntries.add(new ContextDocIdSet(
    entry.context,
    // TODO: can we be smart here, maybe AndDocIdSet is not always fastest?
    new AndDocIdSet(new DocIdSet[]{entry.docSet, filteredSet})
  ));
}

From the JavaDoc for Filter:
NOTE: null can be returned if no documents are accepted by this Filter

So, the filteredSet object can be null. It is then passed into the constructor of the AndDocIdSet, which can cause a null pointer exception during the execution of the POST facet.

The solution is that if filteredSet is null then the current ContextDocIdSet can be ignored.

if (filteredSet == null) continue;

I replicated this issue with the following query (where the filter facet does match a term in the index, but the facet filter does not):

{
  "query": {
    "match_all": {}
  },
  "size": 0,
  "facets": {
    "my_facet": {
      "filter": {
        "term": {
          "text": "document"
        }
      },
      "mode": "post",
      "facet_filter": {
        "term": {
          "text": "DOES_NOT_MATCH_ANYTHING",
        }
      }
    }
  }
}
@dadoonet

This comment has been minimized.

Copy link
Member

dadoonet commented Aug 11, 2013

Fix pushed in 0.90 and master. Thanks for reporting it!

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.