Skip to content

Commit

Permalink
Add fields emulation flag as no-op to search request for bwc (#82539)
Browse files Browse the repository at this point in the history
This change adds the 'enable_fields_emulation' flag as a REST parameter to 8.0+ nodes
in order for clients on 7.last (e.g. Kibana) to be able to use it in rolling upgrade scenarios.
We don't need any implementation of the functionality behind it on 8.0+ nodes, because
CCS is only supported for them to at most 7.last which already understands and
implements the "fields" option, so emulation on older version is not necessary.

Closes #82485
  • Loading branch information
Christoph Büscher authored Jan 13, 2022
1 parent 8a7388c commit 0a05489
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> 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
*/
Expand Down

0 comments on commit 0a05489

Please sign in to comment.