From ea685c43ba3d319f37f17e62013b2274a6f51fd3 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Sun, 12 Apr 2020 16:01:35 +1000 Subject: [PATCH 1/3] Remove local parameter for get field mapping request --- .../indices/GetFieldMappingsRequest.java | 18 ------------- .../IndicesClientDocumentationIT.java | 4 --- .../indices/get_field_mappings.asciidoc | 9 ------- .../indices/get-field-mapping.asciidoc | 6 ----- .../indices.get_field_mapping/10_basic.yml | 7 ++---- .../mapping/get/GetFieldMappingsRequest.java | 25 ++++++------------- .../indices/RestGetFieldMappingAction.java | 14 ----------- 7 files changed, 10 insertions(+), 73 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java index a08c8ec26c590..d24eff3582825 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java @@ -26,9 +26,6 @@ /** Request the mappings of specific fields */ public class GetFieldMappingsRequest implements Validatable { - @Deprecated - private boolean local = false; - private String[] fields = Strings.EMPTY_ARRAY; private boolean includeDefaults = false; @@ -37,21 +34,6 @@ public class GetFieldMappingsRequest implements Validatable { private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); - /** - * Indicate whether the receiving node should operate based on local index information or forward requests, - * where needed, to other nodes. If running locally, request will not raise errors if running locally & missing indices. - */ - @Deprecated - public GetFieldMappingsRequest local(boolean local) { - this.local = local; - return this; - } - - @Deprecated - public boolean local() { - return local; - } - public GetFieldMappingsRequest indices(String... indices) { this.indices = indices; return this; diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java index 5cdf52f7508be..22a550507db78 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java @@ -701,10 +701,6 @@ public void testGetFieldMapping() throws IOException, InterruptedException { request.indicesOptions(IndicesOptions.lenientExpandOpen()); // <1> // end::get-field-mappings-request-indicesOptions - // tag::get-field-mappings-request-local - request.local(true); // <1> - // end::get-field-mappings-request-local - { // tag::get-field-mappings-execute GetFieldMappingsResponse response = diff --git a/docs/java-rest/high-level/indices/get_field_mappings.asciidoc b/docs/java-rest/high-level/indices/get_field_mappings.asciidoc index 4d8117c15fee8..d8124cf651978 100644 --- a/docs/java-rest/high-level/indices/get_field_mappings.asciidoc +++ b/docs/java-rest/high-level/indices/get_field_mappings.asciidoc @@ -30,15 +30,6 @@ include-tagged::{doc-tests-file}[{api}-request-indicesOptions] <1> Setting `IndicesOptions` controls how unavailable indices are resolved and how wildcard expressions are expanded -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests-file}[{api}-request-local] --------------------------------------------------- -<1> deprecated:[7.8.0, This parameter is a no-op and field mappings are always retrieved locally] -The `local` flag (defaults to `false`) controls whether the aliases need -to be looked up in the local cluster state or in the cluster state held by -the elected master node - include::../execution.asciidoc[] [id="{upid}-{api}-response"] diff --git a/docs/reference/indices/get-field-mapping.asciidoc b/docs/reference/indices/get-field-mapping.asciidoc index 95b7959e2161d..f22444843d3ec 100644 --- a/docs/reference/indices/get-field-mapping.asciidoc +++ b/docs/reference/indices/get-field-mapping.asciidoc @@ -48,12 +48,6 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable] (Optional, boolean) If `true`, the response includes default mapping values. Defaults to `false`. -`local`:: -deprecated:[7.8.0, This parameter is a no-op and field mappings are always retrieved locally] -(Optional, boolean) If `true`, the request retrieves information from the local -node only. Defaults to `false`, which means information is retrieved from -the master node. - [[get-field-mapping-api-example]] ==== {api-examples-title} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yml index cf92a4f154be9..350e9ff37f43b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yml @@ -52,18 +52,15 @@ setup: - match: {test_index.mappings.text.mapping.text.analyzer: default} --- -"Get field mapping with local is deprecated": +"Get field mapping with local parameter should fail": - skip: features: ["warnings", "node_selector"] - do: + catch: bad_request node_selector: version: "8.0.0 - " - warnings: - - "Use [local] in get field mapping requests is deprecated. The parameter will be removed in the next major version" indices.get_field_mapping: fields: text local: true - - - match: {test_index.mappings.text.mapping.text.type: text} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java index af0c821fdd8e3..58e751ea4130b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java @@ -39,8 +39,6 @@ */ public class GetFieldMappingsRequest extends ActionRequest implements IndicesRequest.Replaceable { - protected boolean local = false; - private String[] fields = Strings.EMPTY_ARRAY; private boolean includeDefaults = false; @@ -59,26 +57,17 @@ public GetFieldMappingsRequest(StreamInput in) throws IOException { if (types != Strings.EMPTY_ARRAY) { throw new IllegalArgumentException("Expected empty type array but received [" + Arrays.toString(types) + "]"); } + } indicesOptions = IndicesOptions.readIndicesOptions(in); - local = in.readBoolean(); + // Consume the deprecated local parameter + if (in.getVersion().before(Version.V_8_0_0)) { + in.readBoolean(); + } fields = in.readStringArray(); includeDefaults = in.readBoolean(); } - /** - * Indicate whether the receiving node should operate based on local index information or forward requests, - * where needed, to other nodes. If running locally, request will not raise errors if running locally & missing indices. - */ - public GetFieldMappingsRequest local(boolean local) { - this.local = local; - return this; - } - - public boolean local() { - return local; - } - @Override public GetFieldMappingsRequest indices(String... indices) { this.indices = indices; @@ -133,7 +122,9 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(Strings.EMPTY_ARRAY); } indicesOptions.writeIndicesOptions(out); - out.writeBoolean(local); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeBoolean(true); + } out.writeStringArray(fields); out.writeBoolean(includeDefaults); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java index e7847b774bc97..bafcfcdf87fa7 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java @@ -19,15 +19,12 @@ package org.elasticsearch.rest.action.admin.indices; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BytesRestResponse; @@ -46,10 +43,6 @@ public class RestGetFieldMappingAction extends BaseRestHandler { - private static final Logger logger = LogManager.getLogger(RestGetFieldMappingAction.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); - - @Override public List routes() { return List.of( @@ -70,13 +63,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest(); getMappingsRequest.indices(indices).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false)); getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions())); - - if (request.hasParam("local")) { - deprecationLogger.deprecatedAndMaybeLog("get_field_mapping_local", - "Use [local] in get field mapping requests is deprecated. " - + "The parameter will be removed in the next major version"); - } - getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local())); return channel -> client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<>(channel) { @Override From c9661d88dd3a96a1978151102d05bff0aca9a6a3 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Wed, 15 Apr 2020 11:16:45 +1000 Subject: [PATCH 2/3] Add migration notes for the local parameter removal --- docs/reference/migration/migrate_8_0/api.asciidoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/reference/migration/migrate_8_0/api.asciidoc b/docs/reference/migration/migrate_8_0/api.asciidoc index f3293a85d5621..c7f78af9e9563 100644 --- a/docs/reference/migration/migrate_8_0/api.asciidoc +++ b/docs/reference/migration/migrate_8_0/api.asciidoc @@ -17,3 +17,11 @@ to determine the nodes returned by the API rather than the cluster state from the master, but this API requests information from each selected node regardless of the `?local` parameter which means this API does not run in a fully node-local fashion. + + +[float] +==== Deprecated `local` parameter removed from get field mapping API + +The `local` parameter for get field mapping API was deprecated in 7.8 and is +removed in 8.0. This parameter is a no-op and field mappings are always retrieved +locally. From e994ce0010ba33b02b1b92b170fcd630204521aa Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Wed, 15 Apr 2020 11:18:32 +1000 Subject: [PATCH 3/3] Remove extra blank line --- docs/reference/migration/migrate_8_0/api.asciidoc | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/reference/migration/migrate_8_0/api.asciidoc b/docs/reference/migration/migrate_8_0/api.asciidoc index c7f78af9e9563..73327fa59f91d 100644 --- a/docs/reference/migration/migrate_8_0/api.asciidoc +++ b/docs/reference/migration/migrate_8_0/api.asciidoc @@ -18,7 +18,6 @@ the master, but this API requests information from each selected node regardless of the `?local` parameter which means this API does not run in a fully node-local fashion. - [float] ==== Deprecated `local` parameter removed from get field mapping API