From 0c4bbb4ae41f12eb8fbe80fa5f7b455b2b33dedc Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 2 Jun 2017 17:29:32 -0600 Subject: [PATCH 1/2] Add deprecation logging for comma-separated feature parsing This is the deprecation logging and documentation for 5.x related to #24723. It logs when a user does a request like: ``` GET /index/_alias,_mapping ``` --- .../rest/action/admin/indices/RestGetIndicesAction.java | 3 +++ docs/reference/indices/get-index.asciidoc | 4 +++- .../resources/rest-api-spec/test/indices.get/10_basic.yaml | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java index fc6682347fd42..11d48d8207d07 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java @@ -75,6 +75,9 @@ public RestGetIndicesAction( public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] featureParams = request.paramAsStringArray("type", null); + if (featureParams != null && featureParams.length > 1) { + deprecationLogger.deprecated("Requesting comma-separated features is deprecated and will be removed in 6.0+, retrieve all features instead."); + } // Work out if the indices is a list of features if (featureParams == null && indices.length > 0 && indices[0] != null && indices[0].startsWith("_") && !"_all".equals(indices[0])) { featureParams = indices; diff --git a/docs/reference/indices/get-index.asciidoc b/docs/reference/indices/get-index.asciidoc index 772318c71d87a..dabceb22994f9 100644 --- a/docs/reference/indices/get-index.asciidoc +++ b/docs/reference/indices/get-index.asciidoc @@ -19,6 +19,8 @@ all indices by using `_all` or `*` as index. [float] === Filtering index information +deprecated[5.5.0, This comma-separated format is deprecated and will be removed. You can retrieve either a single feature (ie _alias) or all features] + The information returned by the get API can be filtered to include only specific features by specifying a comma delimited list of features in the URL: @@ -27,7 +29,7 @@ by specifying a comma delimited list of features in the URL: GET twitter/_settings,_mappings -------------------------------------------------- // CONSOLE -// TEST[setup:twitter] +// TEST[setup:twitter warning:Requesting comma-separated features is deprecated and will be removed in 6.0+, retrieve all features instead.] The above command will only return the settings and mappings for the index called `twitter`. diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/10_basic.yaml index 54728644f72d2..2c68ed8ffb67b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get/10_basic.yaml @@ -79,7 +79,13 @@ setup: --- "Get index infos should work for wildcards": + - skip: + features: + - warnings + - do: + warnings: + - 'Requesting comma-separated features is deprecated and will be removed in 6.0+, retrieve all features instead.' indices.get: index: test_* feature: _mapping,_settings From b8758c2c4b76afef53f4db500d35e14a303fa699 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 2 Jun 2017 20:37:19 -0600 Subject: [PATCH 2/2] Shorten line length --- .../rest/action/admin/indices/RestGetIndicesAction.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java index 11d48d8207d07..bbca5c402be35 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java @@ -76,7 +76,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] featureParams = request.paramAsStringArray("type", null); if (featureParams != null && featureParams.length > 1) { - deprecationLogger.deprecated("Requesting comma-separated features is deprecated and will be removed in 6.0+, retrieve all features instead."); + deprecationLogger.deprecated("Requesting comma-separated features is deprecated and " + + "will be removed in 6.0+, retrieve all features instead."); } // Work out if the indices is a list of features if (featureParams == null && indices.length > 0 && indices[0] != null && indices[0].startsWith("_") && !"_all".equals(indices[0])) {