diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java index 5023b5e7bb8..e490e869bd1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java @@ -41,7 +41,15 @@ public class XBooleanFilter extends Filter { private DocIdSetIterator getDISI(ArrayList filters, int index, IndexReader reader) throws IOException { - return filters.get(index).getDocIdSet(reader).iterator(); + DocIdSet docIdSet = filters.get(index).getDocIdSet(reader); + if (docIdSet == null) { + return DocIdSet.EMPTY_DOCIDSET.iterator(); + } + DocIdSetIterator iterator = docIdSet.iterator(); + if (iterator == null) { + return DocIdSet.EMPTY_DOCIDSET.iterator(); + } + return iterator; } public List getShouldFilters() {