diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 5be02e346d774..57c3d1e1c5051 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -167,7 +167,10 @@ public static void parseSearchRequest( if (request.hasParam("pre_filter_shard_size")) { searchRequest.setPreFilterShardSize(request.paramAsInt("pre_filter_shard_size", SearchRequest.DEFAULT_PRE_FILTER_SHARD_SIZE)); } - + if (request.hasParam("enable_fields_emulation")) { + // this flag is a no-op from 8.0 on, we only want to consume it so its presence doesn't cause errors + request.paramAsBoolean("enable_fields_emulation", false); + } if (request.hasParam("max_concurrent_shard_requests")) { // only set if we have the parameter since we auto adjust the max concurrency on the coordinator // based on the number of nodes in the cluster diff --git a/server/src/test/java/org/elasticsearch/rest/action/search/RestSearchActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/search/RestSearchActionTests.java index 9a5d6775dbc98..cc27a05d7a49c 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/search/RestSearchActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/search/RestSearchActionTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.test.rest.FakeRestChannel; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.test.rest.RestActionTestCase; import org.junit.Before; @@ -54,6 +55,20 @@ public void testTypeParameter() { assertCriticalWarnings(RestSearchAction.TYPES_DEPRECATION_MESSAGE); } + /** + * The "enable_fields_emulation" flag on search requests is a no-op but should not raise an error + */ + public void testEnableFieldsEmulationNoErrors() throws Exception { + Map params = new HashMap<>(); + params.put("enable_fields_emulation", "true"); + + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withHeaders( + Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader) + ).withMethod(RestRequest.Method.GET).withPath("/some_index/_search").withParams(params).build(); + + action.handleRequest(request, new FakeRestChannel(request, false, 1), verifyingClient); + } + /** * Using an illegal search type on the request should throw an error */