From 8b0daf48f4e7d8a8c377c3e8ad3748b46ff56530 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 22 Oct 2010 17:54:02 +0200 Subject: [PATCH] Query DSL: Query String _missing_ and _exists_ syntax, closes #446. --- .../apache/lucene/queryParser/MissingFieldQueryExtension.java | 4 +++- .../index/query/xcontent/MissingFilterParser.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 4a37896fb57..472c575aed0 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,9 +50,11 @@ public class MissingFieldQueryExtension implements FieldQueryExtension { filter = new TermRangeFilter(fieldName, null, null, true, true); } - filter = new NotFilter(filter); // we always cache this one, really does not change... 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); 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 7bc49a19a43..fb5da145e0a 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,9 +85,11 @@ public class MissingFilterParser extends AbstractIndexComponent implements XCont filter = new TermRangeFilter(fieldName, null, null, true, true); } - filter = new NotFilter(filter); // we always cache this one, really does not change... 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); filter = wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext); if (filterName != null) {