From ba137df093a631d2ef67252930614f0f40c93f01 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 21 Jul 2011 20:21:28 +0300 Subject: [PATCH] Reusing query parser in WrapperQueryParser produces invalid queries, closes #1143. --- .../org/elasticsearch/index/query/WrapperQueryParser.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java index 8f6750cbb13..226fb15ecb9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java @@ -23,7 +23,6 @@ import org.apache.lucene.search.Query; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; @@ -53,7 +52,11 @@ public class WrapperQueryParser implements QueryParser { byte[] querySource = parser.binaryValue(); XContentParser qSourceParser = XContentFactory.xContent(querySource).createParser(querySource); try { - return SearchContext.current().queryParserService().parse(qSourceParser).query(); + final QueryParseContext context = new QueryParseContext(parseContext.index(), parseContext.indexQueryParser); + context.reset(qSourceParser); + Query result = context.parseInnerQuery(); + parser.nextToken(); + return result; } finally { qSourceParser.close(); }