From 1f855f87d9c7ed380c24d9f90dc31268e2b3da9a Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 18 Jan 2018 08:59:31 +0100 Subject: [PATCH 1/3] Deprecate the `update_all_types` option. This option makes no sense on indices that have only one type, which is enforced since 6.0. --- .../rest/action/admin/indices/RestCreateIndexAction.java | 8 ++++++++ .../rest/action/admin/indices/RestPutMappingAction.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java index 6a741fd3951d3..77c397f98556e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java @@ -23,6 +23,8 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; @@ -33,6 +35,9 @@ import java.io.IOException; public class RestCreateIndexAction extends BaseRestHandler { + + private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(RestCreateIndexAction.class)); + public RestCreateIndexAction(Settings settings, RestController controller) { super(settings); controller.registerHandler(RestRequest.Method.PUT, "/{index}", this); @@ -49,6 +54,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC if (request.hasContent()) { createIndexRequest.source(request.content(), request.getXContentType()); } + if (request.hasParam("update_all_types")) { + DEPRECATION_LOGGER.deprecated("[update_all_types] is deprecated since indices may not have more than one type anymore"); + } createIndexRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false)); createIndexRequest.timeout(request.paramAsTime("timeout", createIndexRequest.timeout())); createIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createIndexRequest.masterNodeTimeout())); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java index 8d7e4a9e6c836..473d8ba005436 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java @@ -23,6 +23,8 @@ 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.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; @@ -36,6 +38,9 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutMappingAction extends BaseRestHandler { + + private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(RestPutMappingAction.class)); + public RestPutMappingAction(Settings settings, RestController controller) { super(settings); controller.registerHandler(PUT, "/{index}/_mapping/", this); @@ -70,6 +75,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index"))); putMappingRequest.type(request.param("type")); putMappingRequest.source(request.requiredContent(), request.getXContentType()); + if (request.hasParam("update_all_types")) { + DEPRECATION_LOGGER.deprecated("[update_all_types] is deprecated since indices may not have more than one type anymore"); + } putMappingRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false)); putMappingRequest.timeout(request.paramAsTime("timeout", putMappingRequest.timeout())); putMappingRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putMappingRequest.masterNodeTimeout())); From 6520288d27dafae65526a54c3babfded9e725af8 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 18 Jan 2018 10:40:30 +0100 Subject: [PATCH 2/3] iter --- .../action/admin/indices/create/CreateIndexRequest.java | 4 +++- .../admin/indices/create/CreateIndexRequestBuilder.java | 4 +++- .../admin/indices/mapping/put/PutMappingRequest.java | 7 ++++++- .../indices/mapping/put/PutMappingRequestBuilder.java | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index 8c11377523387..3b4476574b2bc 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -440,7 +440,9 @@ public boolean updateAllTypes() { return updateAllTypes; } - /** See {@link #updateAllTypes()} */ + /** See {@link #updateAllTypes()} + * @deprecated useless with 6.x indices which may only have one type */ + @Deprecated public CreateIndexRequest updateAllTypes(boolean updateAllTypes) { this.updateAllTypes = updateAllTypes; return this; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java index fabe269124e9e..0d0dd7eb3c09e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -239,7 +239,9 @@ public CreateIndexRequestBuilder setSource(XContentBuilder source) { return this; } - /** True if all fields that span multiple types should be updated, false otherwise */ + /** True if all fields that span multiple types should be updated, false otherwise + * @deprecated useless with 6.x indices which may only have one type */ + @Deprecated public CreateIndexRequestBuilder setUpdateAllTypes(boolean updateAllTypes) { request.updateAllTypes(updateAllTypes); return this; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index eecbbc453ee4d..15195a0482cc2 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -295,7 +295,12 @@ public boolean updateAllTypes() { return updateAllTypes; } - /** See {@link #updateAllTypes()} */ + /** + * True if all fields that span multiple types should be updated, false otherwise. + * @deprecated useless with 6.x indices which may only have one type + * @see {@link #updateAllTypes()} + */ + @Deprecated public PutMappingRequest updateAllTypes(boolean updateAllTypes) { this.updateAllTypes = updateAllTypes; return this; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index 43bfe78c4871b..e6fcd841130ef 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -98,7 +98,9 @@ public PutMappingRequestBuilder setSource(Object... source) { return this; } - /** True if all fields that span multiple types should be updated, false otherwise */ + /** True if all fields that span multiple types should be updated, false otherwise + * @deprecated useless with 6.x indices which may only have one type */ + @Deprecated public PutMappingRequestBuilder setUpdateAllTypes(boolean updateAllTypes) { request.updateAllTypes(updateAllTypes); return this; From e091060ddfa31042260bcbbe760854cbfb8ec9d7 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Mon, 22 Jan 2018 15:47:11 +0100 Subject: [PATCH 3/3] iter --- .../action/admin/indices/mapping/put/PutMappingRequest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index 15195a0482cc2..cc2ce228e4133 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -298,7 +298,6 @@ public boolean updateAllTypes() { /** * True if all fields that span multiple types should be updated, false otherwise. * @deprecated useless with 6.x indices which may only have one type - * @see {@link #updateAllTypes()} */ @Deprecated public PutMappingRequest updateAllTypes(boolean updateAllTypes) {