From fbf9197b857594ff6ead04e457b86b771d4c2d25 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 1 Mar 2010 22:17:17 +0200 Subject: [PATCH] make non negative query in query parser --- .../index/query/support/MapperQueryParser.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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;