make non negative query in query parser

This commit is contained in:
kimchy 2010-03-01 22:17:17 +02:00
parent 7709c68f63
commit fbf9197b85
1 changed files with 11 additions and 0 deletions

View File

@ -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<BooleanClause> 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;