optimize query parsing to use single field parser when executing on single field
This commit is contained in:
parent
2c8c6aa22a
commit
ff6d7254fe
|
@ -131,7 +131,7 @@ public class FieldQueryParser extends AbstractIndexComponent implements XContent
|
|||
return query;
|
||||
}
|
||||
|
||||
MapperQueryParser queryParser = parseContext.queryParser(qpSettings);
|
||||
MapperQueryParser queryParser = parseContext.singleQueryParser(qpSettings);
|
||||
|
||||
try {
|
||||
query = queryParser.parse(qpSettings.queryString());
|
||||
|
|
|
@ -104,12 +104,12 @@ public class QueryParseContext {
|
|||
return indexQueryParser.indexCache;
|
||||
}
|
||||
|
||||
public MapperQueryParser queryParser(QueryParserSettings settings) {
|
||||
public MapperQueryParser singleQueryParser(QueryParserSettings settings) {
|
||||
queryParser.reset(settings);
|
||||
return queryParser;
|
||||
}
|
||||
|
||||
public MultiFieldMapperQueryParser queryParser(MultiFieldQueryParserSettings settings) {
|
||||
public MultiFieldMapperQueryParser multiQueryParser(MultiFieldQueryParserSettings settings) {
|
||||
multiFieldQueryParser.reset(settings);
|
||||
return multiFieldQueryParser;
|
||||
}
|
||||
|
|
|
@ -177,13 +177,13 @@ public class QueryStringQueryParser extends AbstractIndexComponent implements XC
|
|||
if (qpSettings.fields() != null) {
|
||||
if (qpSettings.fields().size() == 1) {
|
||||
qpSettings.defaultField(qpSettings.fields().get(0));
|
||||
queryParser = parseContext.queryParser(qpSettings);
|
||||
queryParser = parseContext.singleQueryParser(qpSettings);
|
||||
} else {
|
||||
qpSettings.defaultField(null); // reset defaultField when using multi query parser
|
||||
queryParser = parseContext.queryParser(qpSettings);
|
||||
queryParser = parseContext.multiQueryParser(qpSettings);
|
||||
}
|
||||
} else {
|
||||
queryParser = parseContext.queryParser(qpSettings);
|
||||
queryParser = parseContext.singleQueryParser(qpSettings);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue