Selaa lähdekoodia

Remove local parameter for get field mapping API (#55100)

The local parameter of get field mapping API is marked as deprecated in 7.x.
This PR removes it for v8.0
Yang Wang 5 vuotta sitten
vanhempi
commit
92427d3758

+ 0 - 18
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetFieldMappingsRequest.java

@@ -26,9 +26,6 @@ import org.elasticsearch.common.Strings;
 /** 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;

+ 0 - 4
client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

@@ -701,10 +701,6 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
         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 =

+ 0 - 9
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"]

+ 0 - 6
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}

+ 7 - 0
docs/reference/migration/migrate_8_0/api.asciidoc

@@ -17,3 +17,10 @@ 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.

+ 2 - 5
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}

+ 8 - 17
server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java

@@ -39,8 +39,6 @@ import java.util.Arrays;
  */
 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 class GetFieldMappingsRequest extends ActionRequest implements IndicesReq
             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 &amp; 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 class GetFieldMappingsRequest extends ActionRequest implements IndicesReq
             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);
     }

+ 0 - 14
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 @@ import static org.elasticsearch.rest.RestStatus.OK;
 
 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<Route> routes() {
         return List.of(
@@ -70,13 +63,6 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
         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