From ff6d7254fe230d332ba3fd131686cf2733307f6f Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 3 Jan 2011 15:14:28 +0200 Subject: [PATCH] optimize query parsing to use single field parser when executing on single field --- .../index/query/xcontent/FieldQueryParser.java | 2 +- .../index/query/xcontent/QueryParseContext.java | 4 ++-- .../index/query/xcontent/QueryStringQueryParser.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FieldQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FieldQueryParser.java index 13d3760f699..c6656fab326 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FieldQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FieldQueryParser.java @@ -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()); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryParseContext.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryParseContext.java index b0ff9381afb..e7a8036282d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryParseContext.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryParseContext.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryStringQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryStringQueryParser.java index 595201afb31..73e8dca8ac2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryStringQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/QueryStringQueryParser.java @@ -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); }