correct IndexQueryParserService.parse(QueryBuilder<?>) so that it doesn't convert to JSON and back again
This commit is contained in:
parent
f54155195a
commit
cc9519eee3
|
@ -154,20 +154,14 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
//norelease this needs to go away
|
//norelease this needs to go away
|
||||||
public ParsedQuery parse(QueryBuilder queryBuilder) {
|
public ParsedQuery parse(QueryBuilder<?> queryBuilder) {
|
||||||
XContentParser parser = null;
|
QueryShardContext context = cache.get();
|
||||||
try {
|
try {
|
||||||
BytesReference bytes = queryBuilder.buildAsBytes();
|
return innerParse(context, queryBuilder);
|
||||||
parser = XContentFactory.xContent(bytes).createParser(bytes);
|
|
||||||
return innerParse(cache.get(), parser);
|
|
||||||
} catch (ParsingException e) {
|
} catch (ParsingException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException(parser == null ? null : parser.getTokenLocation(), "Failed to parse", e);
|
throw new QueryShardException(context, "failed to create query: {}", queryBuilder);
|
||||||
} finally {
|
|
||||||
if (parser != null) {
|
|
||||||
parser.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +230,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public QueryBuilder parseInnerQueryBuilder(QueryParseContext parseContext) throws IOException {
|
public QueryBuilder<?> parseInnerQueryBuilder(QueryParseContext parseContext) throws IOException {
|
||||||
parseContext.parseFieldMatcher(parseFieldMatcher);
|
parseContext.parseFieldMatcher(parseFieldMatcher);
|
||||||
return parseContext.parseInnerQueryBuilder();
|
return parseContext.parseInnerQueryBuilder();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +304,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);
|
Query query = queryBuilder.toQuery(context);
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
query = Queries.newMatchNoDocsQuery();
|
query = Queries.newMatchNoDocsQuery();
|
||||||
|
|
Loading…
Reference in New Issue