diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/support/MapperQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/support/MapperQueryParser.java index ad00195523d..04a984a595c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/support/MapperQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/support/MapperQueryParser.java @@ -22,6 +22,7 @@ package org.elasticsearch.index.query.support; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.queryParser.QueryParser; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; import org.apache.lucene.util.Version; @@ -31,6 +32,8 @@ import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.util.Nullable; +import java.util.List; + import static org.elasticsearch.index.query.support.QueryParsers.*; /** @@ -137,6 +140,14 @@ public class MapperQueryParser extends QueryParser { return super.getWildcardQuery(indexedNameField, termStr); } + @Override protected Query getBooleanQuery(List clauses, boolean disableCoord) throws ParseException { + Query q = super.getBooleanQuery(clauses, disableCoord); + if (q == null) { + return null; + } + return fixNegativeQueryIfNeeded(q); + } + protected FieldMapper fieldMapper(String smartName) { if (mapperService == null) { return null;