diff --git a/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java b/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java index 472c575aed0..197494b8853 100644 --- a/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java +++ b/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java @@ -50,11 +50,11 @@ public class MissingFieldQueryExtension implements FieldQueryExtension { filter = new TermRangeFilter(fieldName, null, null, true, true); } - // we always cache this one, really does not change... + // we always cache this one, really does not change... (exists) filter = parseContext.cacheFilter(filter); - // we do the cached before the NotFilter, since there is no need to cache the not result, and this - // way we share with the exists filter filter = new NotFilter(filter); + // cache the not filter as well, so it will be faster + filter = parseContext.cacheFilter(filter); filter = wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MissingFilterParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MissingFilterParser.java index fb5da145e0a..e4dc4fe4c48 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MissingFilterParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MissingFilterParser.java @@ -85,11 +85,11 @@ public class MissingFilterParser extends AbstractIndexComponent implements XCont filter = new TermRangeFilter(fieldName, null, null, true, true); } - // we always cache this one, really does not change... + // we always cache this one, really does not change... (exists) filter = parseContext.cacheFilter(filter); - // we do the cached before the NotFilter, since there is no need to cache the not result, and this - // way we share with the exists filter filter = new NotFilter(filter); + // cache the not filter as well, so it will be faster + filter = parseContext.cacheFilter(filter); filter = wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext); if (filterName != null) {