Revert "correct IndexQueryParserService.parse(QueryBuilder<?>) so that it doesn't convert to JSON and back again"

This reverts commit cc9519eee3.
This commit is contained in:
Colin Goodheart-Smithe 2015-09-24 00:00:09 +01:00
parent cc9519eee3
commit 510d1896f7
1 changed files with 12 additions and 6 deletions

View File

@ -154,14 +154,20 @@ public class IndexQueryParserService extends AbstractIndexComponent {
}
//norelease this needs to go away
public ParsedQuery parse(QueryBuilder<?> queryBuilder) {
QueryShardContext context = cache.get();
public ParsedQuery parse(QueryBuilder queryBuilder) {
XContentParser parser = null;
try {
return innerParse(context, queryBuilder);
BytesReference bytes = queryBuilder.buildAsBytes();
parser = XContentFactory.xContent(bytes).createParser(bytes);
return innerParse(cache.get(), parser);
} catch (ParsingException e) {
throw e;
} catch (Exception e) {
throw new QueryShardException(context, "failed to create query: {}", queryBuilder);
throw new ParsingException(parser == null ? null : parser.getTokenLocation(), "Failed to parse", e);
} finally {
if (parser != null) {
parser.close();
}
}
}
@ -230,7 +236,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
}
@Nullable
public QueryBuilder<?> parseInnerQueryBuilder(QueryParseContext parseContext) throws IOException {
public QueryBuilder parseInnerQueryBuilder(QueryParseContext parseContext) throws IOException {
parseContext.parseFieldMatcher(parseFieldMatcher);
return parseContext.parseInnerQueryBuilder();
}
@ -304,7 +310,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
}
}
private static ParsedQuery innerParse(QueryShardContext context, QueryBuilder<?> queryBuilder) throws IOException, QueryShardException {
private static ParsedQuery innerParse(QueryShardContext context, QueryBuilder queryBuilder) throws IOException, QueryShardException {
Query query = queryBuilder.toQuery(context);
if (query == null) {
query = Queries.newMatchNoDocsQuery();