Only log one types warning per bulk search request. (#37446)
This commit is contained in:
parent
e7511753a9
commit
0a3bff2ca9
|
@ -79,6 +79,14 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler {
|
|||
@Override
|
||||
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
|
||||
MultiSearchTemplateRequest multiRequest = parseRequest(request, allowExplicitIndex);
|
||||
|
||||
// Emit a single deprecation message if any search template contains types.
|
||||
for (SearchTemplateRequest searchTemplateRequest : multiRequest.requests()) {
|
||||
if (searchTemplateRequest.getRequest().types().length > 0) {
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return channel -> client.execute(MultiSearchTemplateAction.INSTANCE, multiRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
|
@ -93,9 +101,6 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler {
|
|||
|
||||
RestMultiSearchAction.parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex,
|
||||
(searchRequest, bytes) -> {
|
||||
if (searchRequest.types().length > 0) {
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_template_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
SearchTemplateRequest searchTemplateRequest = SearchTemplateRequest.fromXContent(bytes);
|
||||
if (searchTemplateRequest.getScript() != null) {
|
||||
searchTemplateRequest.setRequest(searchRequest);
|
||||
|
|
|
@ -77,8 +77,6 @@ public class MultiSearchTemplateRequestTests extends ESTestCase {
|
|||
assertEquals(1, request.requests().get(0).getScriptParams().size());
|
||||
assertEquals(1, request.requests().get(1).getScriptParams().size());
|
||||
assertEquals(1, request.requests().get(2).getScriptParams().size());
|
||||
|
||||
assertWarnings(RestMultiSearchTemplateAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
public void testParseWithCarriageReturn() throws Exception {
|
||||
|
|
|
@ -88,6 +88,14 @@ public class RestMultiSearchAction extends BaseRestHandler {
|
|||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
MultiSearchRequest multiSearchRequest = parseRequest(request, allowExplicitIndex);
|
||||
|
||||
// Emit a single deprecation message if any search request contains types.
|
||||
for (SearchRequest searchRequest : multiSearchRequest.requests()) {
|
||||
if (searchRequest.types().length > 0) {
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return channel -> client.multiSearch(multiSearchRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
|
@ -114,9 +122,6 @@ public class RestMultiSearchAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex, (searchRequest, parser) -> {
|
||||
if (searchRequest.types().length > 0) {
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
searchRequest.source(SearchSourceBuilder.fromXContent(parser, false));
|
||||
RestSearchAction.checkRestTotalHits(restRequest, searchRequest);
|
||||
multiRequest.add(searchRequest);
|
||||
|
|
Loading…
Reference in New Issue