Reusing query parser in WrapperQueryParser produces invalid queries, closes #1143.

This commit is contained in:
kimchy 2011-07-21 20:21:28 +03:00
parent fbd6e85eac
commit ba137df093
1 changed files with 5 additions and 2 deletions

View File

@ -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();
}