cleanup request parsing in RestSearchAction
This commit is contained in:
parent
44b3dc95a0
commit
22e12ab7c3
|
@ -92,7 +92,7 @@ public class RestSearchAction extends BaseRestHandler {
|
|||
@Override
|
||||
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws IOException {
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
RestSearchAction.parseSearchRequest(searchRequest, queryRegistry, request, parseFieldMatcher, aggParsers, suggesters, null);
|
||||
parseSearchRequest(searchRequest, queryRegistry, request, parseFieldMatcher, aggParsers, suggesters, null);
|
||||
client.search(searchRequest, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
|
@ -123,16 +123,15 @@ public class RestSearchAction extends BaseRestHandler {
|
|||
}
|
||||
if (restContent != null) {
|
||||
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry);
|
||||
if (isTemplateRequest) {
|
||||
try (XContentParser parser = XContentFactory.xContent(restContent).createParser(restContent)) {
|
||||
context.reset(parser);
|
||||
context.parseFieldMatcher(parseFieldMatcher);
|
||||
try (XContentParser parser = XContentFactory.xContent(restContent).createParser(restContent)) {
|
||||
context.reset(parser);
|
||||
context.parseFieldMatcher(parseFieldMatcher);
|
||||
if (isTemplateRequest) {
|
||||
Template template = TemplateQueryParser.parse(parser, context.parseFieldMatcher(), "params", "template");
|
||||
searchRequest.template(template);
|
||||
} else {
|
||||
searchRequest.source().parseXContent(parser, context, aggParsers, suggesters);
|
||||
}
|
||||
} else {
|
||||
RestActions.parseRestSearchSource(searchRequest.source(), restContent, indicesQueriesRegistry, parseFieldMatcher,
|
||||
aggParsers, suggesters);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,17 +115,6 @@ public class RestActions {
|
|||
return queryBuilder;
|
||||
}
|
||||
|
||||
public static void parseRestSearchSource(SearchSourceBuilder source, BytesReference sourceBytes,
|
||||
IndicesQueriesRegistry queryRegistry, ParseFieldMatcher parseFieldMatcher,
|
||||
AggregatorParsers aggParsers, Suggesters suggesters)
|
||||
throws IOException {
|
||||
XContentParser parser = XContentFactory.xContent(sourceBytes).createParser(sourceBytes);
|
||||
QueryParseContext queryParseContext = new QueryParseContext(queryRegistry);
|
||||
queryParseContext.reset(parser);
|
||||
queryParseContext.parseFieldMatcher(parseFieldMatcher);
|
||||
source.parseXContent(parser, queryParseContext, aggParsers, suggesters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rest content from either payload or source parameter
|
||||
* @param request Rest request
|
||||
|
|
Loading…
Reference in New Issue