From cb276231b113ba4848c4fb04f2e43d2c548a361e Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Mon, 11 May 2020 11:39:06 -0600 Subject: [PATCH] Remove prefer_v2_templates query string parameter This commit removes the `prefer_v2_templates` flag and setting. This was a brief setting that allowed specifying whether V1 or V2 template should be used when an index is created. It has been removed in favor of V2 templates always having priority. Relates to #53101 Resolves #56528 This is not a breaking change because this flag was never in a released version. --- .../client/IndicesRequestConverters.java | 3 - .../client/RequestConverters.java | 14 - .../client/indices/CreateIndexRequest.java | 12 - .../org/elasticsearch/client/ReindexIT.java | 47 ---- docs/reference/api-conventions.asciidoc | 4 +- .../indices/index-templates.asciidoc | 8 +- docs/reference/indices/templates.asciidoc | 8 +- .../migration/migrate_8_0/settings.asciidoc | 18 -- .../index/reindex/Reindexer.java | 6 - .../index/reindex/RestReindexAction.java | 4 - .../resources/rest-api-spec/api/bulk.json | 4 - .../resources/rest-api-spec/api/create.json | 4 - .../resources/rest-api-spec/api/index.json | 4 - .../rest-api-spec/api/indices.create.json | 4 - .../rest-api-spec/api/indices.rollover.json | 4 - .../resources/rest-api-spec/api/reindex.json | 4 - .../resources/rest-api-spec/api/update.json | 4 - .../15_composition.yml | 33 --- .../template/TemplatePreferenceIT.java | 254 ------------------ .../CreateIndexClusterStateUpdateRequest.java | 13 - .../indices/create/CreateIndexRequest.java | 19 -- .../create/TransportCreateIndexAction.java | 1 - .../rollover/MetadataRolloverService.java | 3 +- .../rollover/TransportRolloverAction.java | 8 - .../action/bulk/BulkRequest.java | 18 -- .../action/bulk/TransportBulkAction.java | 13 +- .../TransportSingleItemBulkWriteAction.java | 4 - .../action/index/IndexRequest.java | 17 -- .../action/update/TransportUpdateAction.java | 1 - .../action/update/UpdateRequest.java | 17 -- .../cluster/metadata/IndexMetadata.java | 5 - .../metadata/MetadataCreateIndexService.java | 29 +- .../common/settings/IndexScopedSettings.java | 1 - .../index/reindex/ReindexRequest.java | 20 -- .../admin/indices/RestCreateIndexAction.java | 8 - .../indices/RestRolloverIndexAction.java | 1 - .../rest/action/document/RestBulkAction.java | 2 - .../rest/action/document/RestIndexAction.java | 2 - .../action/document/RestUpdateAction.java | 2 - ...ActionIndicesThatCannotBeCreatedTests.java | 3 +- .../bulk/TransportBulkActionIngestTests.java | 5 +- .../action/bulk/TransportBulkActionTests.java | 23 +- .../action/TransportResumeFollowAction.java | 1 - 43 files changed, 32 insertions(+), 623 deletions(-) delete mode 100644 server/src/internalClusterTest/java/org/elasticsearch/indices/template/TemplatePreferenceIT.java diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java index e9e2fa13595c4..7ee92a4a89e9c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java @@ -114,9 +114,6 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep parameters.withTimeout(createIndexRequest.timeout()); parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout()); parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards()); - if (createIndexRequest.preferV2Templates() != null) { - parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(createIndexRequest.preferV2Templates())); - } request.addParameters(parameters.asMap()); request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); return request; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index 525d0b8b19f21..be9dfc4ca7a1e 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -56,7 +56,6 @@ import org.elasticsearch.client.security.RefreshPolicy; import org.elasticsearch.client.tasks.TaskId; import org.elasticsearch.cluster.health.ClusterHealthStatus; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; @@ -133,9 +132,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException { parameters.withRefreshPolicy(bulkRequest.getRefreshPolicy()); parameters.withPipeline(bulkRequest.pipeline()); parameters.withRouting(bulkRequest.routing()); - if (bulkRequest.preferV2Templates() != null) { - parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(bulkRequest.preferV2Templates())); - } // Bulk API only supports newline delimited JSON or Smile. Before executing // the bulk, we need to check that all requests have the same content-type // and this content-type is supported by the Bulk API. @@ -336,9 +332,6 @@ static Request index(IndexRequest indexRequest) { parameters.withPipeline(indexRequest.getPipeline()); parameters.withRefreshPolicy(indexRequest.getRefreshPolicy()); parameters.withWaitForActiveShards(indexRequest.waitForActiveShards()); - if (indexRequest.preferV2Templates() != null) { - parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(indexRequest.preferV2Templates())); - } BytesRef source = indexRequest.source().toBytesRef(); ContentType contentType = createContentType(indexRequest.getContentType()); @@ -365,9 +358,6 @@ static Request update(UpdateRequest updateRequest) throws IOException { parameters.withRetryOnConflict(updateRequest.retryOnConflict()); parameters.withVersion(updateRequest.version()); parameters.withVersionType(updateRequest.versionType()); - if (updateRequest.preferV2Templates() != null) { - parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(updateRequest.preferV2Templates())); - } // The Java API allows update requests with different content types // set for the partial document and the upsert document. This client @@ -579,10 +569,6 @@ private static Request prepareReindexRequest(ReindexRequest reindexRequest, bool params.putParam("scroll", reindexRequest.getScrollTime()); } - if (reindexRequest.preferV2Templates() != null) { - params.putParam("prefer_v2_templates", reindexRequest.preferV2Templates().toString()); - } - request.addParameters(params.asMap()); request.setEntity(createEntity(reindexRequest, REQUEST_BODY_CONTENT_TYPE)); return request; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java index 2e55165b5746d..1a018591dc770 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java @@ -25,7 +25,6 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.TimedRequest; import org.elasticsearch.client.Validatable; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; @@ -63,7 +62,6 @@ public class CreateIndexRequest extends TimedRequest implements Validatable, ToX private BytesReference mappings; private XContentType mappingsXContentType; - private Boolean preferV2Templates; private final Set aliases = new HashSet<>(); @@ -267,16 +265,6 @@ public CreateIndexRequest aliases(Collection aliases) { return this; } - public CreateIndexRequest preferV2Templates(Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - - @Nullable - public Boolean preferV2Templates() { - return this.preferV2Templates; - } - /** * Sets the settings and mappings as a single source. * diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ReindexIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ReindexIT.java index 2d76234c05b0d..1c33a7e183e5a 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ReindexIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ReindexIT.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup; -import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.get.GetRequest; @@ -31,12 +30,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.client.indices.PutIndexTemplateRequest; -import org.elasticsearch.client.indices.PutIndexTemplateV2Request; import org.elasticsearch.client.tasks.TaskSubmissionResponse; -import org.elasticsearch.cluster.metadata.AliasMetadata; -import org.elasticsearch.cluster.metadata.IndexTemplateV2; -import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.common.CheckedRunnable; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -56,9 +50,6 @@ import java.io.IOException; import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -122,44 +113,6 @@ public void testReindex() throws IOException { } } - public void testReindexPreferV2Templates() throws Exception { - //we don't care about warnings here - RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> false).build(); - - IndexRequest indexRequest = new IndexRequest("sourcev2").source(Collections.singletonMap("foo", "bar"), XContentType.JSON); - indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - RestHighLevelClient client = highLevelClient(); - assertEquals(RestStatus.CREATED, client.index(indexRequest, options).status()); - - PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest("v1", Collections.singletonList("target*")); - assertTrue(client.indices().putTemplate(putIndexTemplateRequest, options).isAcknowledged()); - - AliasMetadata alias = AliasMetadata.builder("alias").build(); - Template template = new Template(null, null, Map.of("alias", alias)); - List pattern = Collections.singletonList("target*"); - IndexTemplateV2 indexTemplate = new IndexTemplateV2(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>()); - PutIndexTemplateV2Request putTemplateRequest = new PutIndexTemplateV2Request().name("v2").indexTemplate(indexTemplate); - assertTrue(client.indices().putIndexTemplate(putTemplateRequest, options).isAcknowledged()); - - ReindexRequest reindexRequest = new ReindexRequest() - .preferV2Templates(true) - .setSourceIndices("sourcev2") - .setDestIndex("target1") - .setRefresh(true); - assertEquals(1, client.reindex(reindexRequest, options).getStatus().getSuccessfullyProcessed()); - - GetAliasesResponse aliases = client.indices().getAlias(new GetAliasesRequest().indices("target1"), options); - assertEquals(RestStatus.OK, aliases.status()); - assertEquals(Collections.singletonMap("target1", Collections.singleton(alias)), aliases.getAliases()); - - reindexRequest.setDestIndex("target2").preferV2Templates(false); - assertEquals(1, client.reindex(reindexRequest, options).getStatus().getSuccessfullyProcessed()); - - aliases = client.indices().getAlias(new GetAliasesRequest().indices("target2"), options); - assertEquals(RestStatus.OK, aliases.status()); - assertEquals(Collections.singletonMap("target2", Collections.emptySet()), aliases.getAliases()); - } - public void testReindexTask() throws Exception { final String sourceIndex = "source123"; final String destinationIndex = "dest2"; diff --git a/docs/reference/api-conventions.asciidoc b/docs/reference/api-conventions.asciidoc index 2274d3819d50d..3921aab0d1354 100644 --- a/docs/reference/api-conventions.asciidoc +++ b/docs/reference/api-conventions.asciidoc @@ -385,7 +385,6 @@ Returns: "settings": { "index.number_of_replicas": "1", "index.number_of_shards": "1", - "index.prefer_v2_templates": "true", "index.creation_date": "1474389951325", "index.uuid": "n6gzFZTgS664GUfx0Xrpjw", "index.version.created": ..., @@ -422,8 +421,7 @@ Returns: "version": { "created": ... }, - "provided_name" : "twitter", - "prefer_v2_templates": "true" + "provided_name" : "twitter" } } } diff --git a/docs/reference/indices/index-templates.asciidoc b/docs/reference/indices/index-templates.asciidoc index 59d37804a9888..d4f87601dbf68 100644 --- a/docs/reference/indices/index-templates.asciidoc +++ b/docs/reference/indices/index-templates.asciidoc @@ -9,11 +9,9 @@ This documentation is about V2 (version 2) index templates. For V1 templates ple [NOTE] ==== -In {es} 7.8 the `prefer_v2_templates` querystring parameter was introduced to the index, update, -bulk, and create index APIs to allow configuring whether to favor V2 or V1 index templates. In 7.x -the default value for this parameter is `false` meaning that the <> take precedence. In 8.x the default value for the parameter is `true` meaning that V2 -index templates take precedence (V1 templates may still match if no V2 template matches). +In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always +takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match +and be applied. ==== An index template is a way to tell {es} how to configure an index when it is created. Templates are diff --git a/docs/reference/indices/templates.asciidoc b/docs/reference/indices/templates.asciidoc index df53ccf921965..bf5173b612f98 100644 --- a/docs/reference/indices/templates.asciidoc +++ b/docs/reference/indices/templates.asciidoc @@ -9,11 +9,9 @@ replaced by V2 templates. For information about V2 templates, see <> take precedence (V1 templates may still match if no V2 template matches). +In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always +takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match +and be applied. ==== Creates or updates an index template. diff --git a/docs/reference/migration/migrate_8_0/settings.asciidoc b/docs/reference/migration/migrate_8_0/settings.asciidoc index e5dd3dcca627d..802b39daa1742 100644 --- a/docs/reference/migration/migrate_8_0/settings.asciidoc +++ b/docs/reference/migration/migrate_8_0/settings.asciidoc @@ -144,21 +144,3 @@ may be set to false. Discontinue use of the removed settings. Specifying these settings in `elasticsearch.yml` will result in an error on startup. ==== - -.The `prefer_v2_templates` parameter now defaults to `true` for several document and index APIs. -[%collapsible] -==== -*Details* + -In Elasticsearch 7.8.0 the `?prefer_v2_templates=true|false` parameter was introduced to allow -specifying whether to favor V1 or V2 templates when a new index is created. In 8.0 this now defaults -to `true`, meaning that V2 index templates will always take precedence if they match. V1 templates -will continue to be applied if no V2 index template matches the newly created index pattern. - -The `?prefer_v2_templates` parameter is supported on the <>, -<>, <>, <>, and -<> APIs. - -*Impact* + -Update your workflow and applications to assume a default value of `true` for -the `prefer_v2_templates` query parameter. -==== diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/Reindexer.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/Reindexer.java index 976922188f4be..39879845bdca1 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/Reindexer.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/Reindexer.java @@ -32,7 +32,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.bulk.BackoffPolicy; import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.Client; import org.elasticsearch.client.ParentTaskAssigningClient; @@ -218,11 +217,6 @@ public BiFunction, ScrollableHitSource.Hit, RequestWrapper> return super.buildScriptApplier(); } - @Override - protected BulkRequest buildBulk(Iterable docs) { - return super.buildBulk(docs).preferV2Templates(mainRequest.preferV2Templates()); - } - @Override protected RequestWrapper buildRequest(ScrollableHitSource.Hit doc) { IndexRequest index = new IndexRequest(); diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java index 54ef411a60469..25b95708681a0 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java @@ -69,10 +69,6 @@ protected ReindexRequest buildRequest(RestRequest request) throws IOException { internal.setScroll(parseTimeValue(request.param("scroll"), "scroll")); } - if (request.hasParam("prefer_v2_templates")) { - internal.preferV2Templates(Boolean.parseBoolean(request.param("prefer_v2_templates"))); - } - return internal; } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json b/rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json index 34b4bd9939ad3..085ff88d0c135 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json @@ -87,10 +87,6 @@ "pipeline":{ "type":"string", "description":"The pipeline id to preprocess incoming documents with" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during automatic index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/create.json b/rest-api-spec/src/main/resources/rest-api-spec/api/create.json index 21eca1bc792be..171f3da44d36d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/create.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/create.json @@ -90,10 +90,6 @@ "pipeline":{ "type":"string", "description":"The pipeline id to preprocess incoming documents with" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during automatic index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/index.json b/rest-api-spec/src/main/resources/rest-api-spec/api/index.json index f7fe9ac954001..34608160c915e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/index.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/index.json @@ -92,10 +92,6 @@ "pipeline":{ "type":"string", "description":"The pipeline id to preprocess incoming documents with" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during automatic index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json index da34028d87a78..922183d628ac6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json @@ -33,10 +33,6 @@ "master_timeout":{ "type":"time", "description":"Specify timeout for connection to master" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.rollover.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.rollover.json index 0fd311878736f..fef1f03d1c9a7 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.rollover.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.rollover.json @@ -53,10 +53,6 @@ "wait_for_active_shards":{ "type":"string", "description":"Set the number of active shards to wait for on the newly created rollover index before the operation returns." - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during automatic index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/reindex.json b/rest-api-spec/src/main/resources/rest-api-spec/api/reindex.json index 101eed5ec0bfd..2fbaf86cab616 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/reindex.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/reindex.json @@ -52,10 +52,6 @@ "max_docs":{ "type":"number", "description":"Maximum number of documents to process (default: all documents)" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/update.json b/rest-api-spec/src/main/resources/rest-api-spec/api/update.json index 479a9111ac2a6..45b6f764387eb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/update.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/update.json @@ -99,10 +99,6 @@ "if_primary_term":{ "type":"number", "description":"only perform the update operation if the last operation that has changed the document has the specified primary term" - }, - "prefer_v2_templates": { - "type": "boolean", - "description": "favor V2 templates instead of V1 templates during automatic index creation" } }, "body":{ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/15_composition.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/15_composition.yml index 9ef465bc1a10b..0099ec96b2e9d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/15_composition.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/15_composition.yml @@ -61,7 +61,6 @@ - do: indices.create: index: bar-baz - prefer_v2_templates: true body: settings: index.priority: 17 @@ -121,7 +120,6 @@ - do: indices.create: - prefer_v2_templates: true index: bar-baz - do: @@ -166,7 +164,6 @@ - do: indices.create: - prefer_v2_templates: true index: bazfoo - do: @@ -196,7 +193,6 @@ - do: indices.create: - prefer_v2_templates: true index: eggplant - do: @@ -204,32 +200,3 @@ index: eggplant - match: {eggplant.settings.index.number_of_shards: "3"} - ---- -"Version 1 templates are preferred if the flag is set": - - skip: - version: " - 7.7.99" - reason: "index template v2 API unavailable before 7.8" - features: allowed_warnings - - - do: - allowed_warnings: - - "index template [my-template] has index patterns [eggplant] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template] will take precedence during new index creation" - indices.put_index_template: - name: my-template - body: - index_patterns: ["eggplant"] - template: - settings: - number_of_replicas: 2 - - - do: - indices.create: - prefer_v2_templates: false - index: eggplant - - - do: - indices.get: - index: eggplant - - - match: {eggplant.settings.index.number_of_replicas: "1"} diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/TemplatePreferenceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/template/TemplatePreferenceIT.java deleted file mode 100644 index 287ad77f18a75..0000000000000 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/TemplatePreferenceIT.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.indices.template; - -import org.elasticsearch.action.admin.indices.alias.Alias; -import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; -import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; -import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; -import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateV2Action; -import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action; -import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.cluster.metadata.IndexTemplateV2; -import org.elasticsearch.cluster.metadata.Template; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.test.ESSingleNodeTestCase; -import org.junit.After; -import org.junit.Before; - -import java.util.Collections; - -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; -import static org.hamcrest.Matchers.equalTo; - -public class TemplatePreferenceIT extends ESSingleNodeTestCase { - - private static final String INDEX = "index"; - - @Before - public void setup() throws Exception { - assertAcked(client().admin().indices().preparePutTemplate("v1") - .setSettings(Settings.builder() - .put("index.priority", 15) - .build()) - .setPatterns(Collections.singletonList(INDEX + "*")).get()); - - Template v2Settings = new Template(Settings.builder() - .put("index.priority", 23) - .build(), null, null); - IndexTemplateV2 v2template = new IndexTemplateV2(Collections.singletonList(INDEX + "*"), v2Settings, null, null, null, null); - PutIndexTemplateV2Action.Request request = new PutIndexTemplateV2Action.Request("v2"); - request.indexTemplate(v2template); - assertAcked(client().execute(PutIndexTemplateV2Action.INSTANCE, request).get()); - } - - @After - public void cleanup() throws Exception { - assertAcked(client().admin().indices().prepareDeleteTemplate("v1").get()); - assertAcked(client().execute(DeleteIndexTemplateV2Action.INSTANCE, new DeleteIndexTemplateV2Action.Request("v2")).get()); - } - - public void testCreateIndexPreference() throws Exception { - client().admin().indices().prepareCreate(INDEX).get(); - assertUsedV2(); - - client().admin().indices().create(new CreateIndexRequest(INDEX).preferV2Templates(false)).get(); - assertUsedV1(); - - client().admin().indices().create(new CreateIndexRequest(INDEX).preferV2Templates(true)).get(); - assertUsedV2(); - } - - public void testIndexingRequestPreference() throws Exception { - client().index(new IndexRequest(INDEX).source("foo", "bar")).get(); - assertUsedV2(); - - client().index(new IndexRequest(INDEX).source("foo", "bar").preferV2Templates(false)).get(); - assertUsedV1(); - - client().index(new IndexRequest(INDEX).source("foo", "bar").preferV2Templates(true)).get(); - assertUsedV2(); - - client().update(new UpdateRequest(INDEX, "1").doc("foo", "bar").docAsUpsert(true)).get(); - assertUsedV2(); - - client().update(new UpdateRequest(INDEX, "1").doc("foo", "bar").docAsUpsert(true).preferV2Templates(false)).get(); - assertUsedV1(); - - client().update(new UpdateRequest(INDEX, "1").doc("foo", "bar").docAsUpsert(true).preferV2Templates(true)).get(); - assertUsedV2(); - - client().bulk(new BulkRequest(INDEX).add(new IndexRequest(INDEX).source("foo", "bar"))).get(); - assertUsedV2(); - - client().bulk(new BulkRequest(INDEX).add(new IndexRequest(INDEX).source("foo", "bar")).preferV2Templates(false)).get(); - assertUsedV1(); - - client().bulk(new BulkRequest(INDEX).add(new IndexRequest(INDEX).source("foo", "bar")).preferV2Templates(true)).get(); - assertUsedV2(); - } - - public void testRolloverMaintainsSetting() throws Exception { - { - client().admin().indices().prepareCreate(INDEX + "-1") - .addAlias(new Alias("alias").writeIndex(true)) - .get(); - - client().admin().indices().prepareRolloverIndex("alias").get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().prepareCreate(INDEX + "-1") - .addAlias(new Alias("alias").writeIndex(true)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(false); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V1 template and have priority of 15", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("15")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().prepareCreate(INDEX + "-1") - .addAlias(new Alias("alias").writeIndex(true)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(true); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(false)) - .get(); - - client().admin().indices().prepareRolloverIndex("alias").get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V1 template and have priority of 15", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("15")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(false)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(false); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V1 template and have priority of 15", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("15")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(false)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(true); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(true)) - .get(); - - client().admin().indices().prepareRolloverIndex("alias").get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(true)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(false); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V1 template and have priority of 15", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("15")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - { - client().admin().indices().create(new CreateIndexRequest(INDEX + "-1") - .alias(new Alias("alias").writeIndex(true)) - .preferV2Templates(true)) - .get(); - - RolloverRequest request = new RolloverRequest("alias", INDEX + "-000002"); - request.getCreateIndexRequest().preferV2Templates(true); - client().admin().indices().rolloverIndex(request).get(); - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX + "*").get(); - } - - assertWarnings("index [index-000002] matches multiple v1 templates [one_shard_index_template, " + - "random-soft-deletes-template, v1], v2 index templates will only match a single index template"); - } - - private void assertUsedV1() { - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX).get(); - assertThat("expected index to use V1 template and have priority of 15", - resp.getSetting(INDEX, "index.priority"), equalTo("15")); - client().admin().indices().prepareDelete(INDEX).get(); - } - - private void assertUsedV2() { - GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX).get(); - assertThat("expected index to use V2 template and have priority of 23", - resp.getSetting(INDEX, "index.priority"), equalTo("23")); - client().admin().indices().prepareDelete(INDEX).get(); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexClusterStateUpdateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexClusterStateUpdateRequest.java index 5a0af6a975336..fc035529fb522 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexClusterStateUpdateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexClusterStateUpdateRequest.java @@ -25,7 +25,6 @@ import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; @@ -43,7 +42,6 @@ public class CreateIndexClusterStateUpdateRequest extends ClusterStateUpdateRequ private Index recoverFrom; private ResizeType resizeType; private boolean copySettings; - private Boolean preferV2Templates; private Settings settings = Settings.Builder.EMPTY_SETTINGS; @@ -96,11 +94,6 @@ public CreateIndexClusterStateUpdateRequest copySettings(final boolean copySetti return this; } - public CreateIndexClusterStateUpdateRequest preferV2Templates(@Nullable Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - public String cause() { return cause; } @@ -152,11 +145,6 @@ public boolean copySettings() { return copySettings; } - @Nullable - public Boolean preferV2Templates() { - return preferV2Templates; - } - @Override public String toString() { return "CreateIndexClusterStateUpdateRequest{" + @@ -170,7 +158,6 @@ public String toString() { ", aliases=" + aliases + ", blocks=" + blocks + ", waitForActiveShards=" + waitForActiveShards + - ", preferV2Templates=" + preferV2Templates + '}'; } } 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 cd2ea730f512d..58b65a80b3844 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 @@ -29,7 +29,6 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedRequest; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; @@ -81,8 +80,6 @@ public class CreateIndexRequest extends AcknowledgedRequest private String mappings = "{}"; - private Boolean preferV2Templates; - private final Set aliases = new HashSet<>(); private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT; @@ -110,9 +107,6 @@ public CreateIndexRequest(StreamInput in) throws IOException { aliases.add(new Alias(in)); } waitForActiveShards = ActiveShardCount.readFrom(in); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { - preferV2Templates = in.readOptionalBoolean(); - } } public CreateIndexRequest() { @@ -164,16 +158,6 @@ public CreateIndexRequest index(String index) { return this; } - public CreateIndexRequest preferV2Templates(@Nullable Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - - @Nullable - public Boolean preferV2Templates() { - return this.preferV2Templates; - } - /** * The settings to create the index with. */ @@ -484,9 +468,6 @@ public void writeTo(StreamOutput out) throws IOException { alias.writeTo(out); } waitForActiveShards.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { - out.writeOptionalBoolean(preferV2Templates); - } } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java index a2089f68425cc..cce4abdbc4ca8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -88,7 +88,6 @@ static void innerCreateIndex(CreateIndexRequest request, .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout()) .settings(request.settings()).mappings(request.mappings()) .aliases(request.aliases()) - .preferV2Templates(request.preferV2Templates()) .waitForActiveShards(request.waitForActiveShards()); createIndexService.createIndex(updateRequest, ActionListener.map(listener, response -> diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java index 2f3ff6b7d1bd7..0c6e178274f1d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java @@ -199,8 +199,7 @@ static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest(final Stri .settings(b.build()) .aliases(createIndexRequest.aliases()) .waitForActiveShards(ActiveShardCount.NONE) // not waiting for shards here, will wait on the alias switch operation - .mappings(createIndexRequest.mappings()) - .preferV2Templates(createIndexRequest.preferV2Templates()); + .mappings(createIndexRequest.mappings()); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java index 91ef64dfe0803..2e048b16f831a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -40,7 +40,6 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.tasks.Task; @@ -129,13 +128,6 @@ public void onResponse(IndicesStatsResponse statsResponse) { + rolloverIndexName + "]", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) throws Exception { - // If they haven't explicitly specified whether to use V2 or V1 templates, inherit their preference - // from the existing index (the source index) settings. - if (rolloverRequest.getCreateIndexRequest().preferV2Templates() == null) { - Settings originalIndexSettings = currentState.metadata().index(sourceIndexName).getSettings(); - rolloverRequest.getCreateIndexRequest() - .preferV2Templates(IndexMetadata.PREFER_V2_TEMPLATES_SETTING.get(originalIndexSettings)); - } MetadataRolloverService.RolloverResult rolloverResult = rolloverService.rolloverClusterState(currentState, rolloverRequest.getRolloverTarget(), rolloverRequest.getNewIndexName(), rolloverRequest.getCreateIndexRequest(), metConditions, false); diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 8963bb91f9c0b..9484e1582d93c 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.bulk; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -74,7 +73,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques private String globalPipeline; private String globalRouting; private String globalIndex; - private Boolean preferV2Templates; private long sizeInBytes = 0; @@ -89,9 +87,6 @@ public BulkRequest(StreamInput in) throws IOException { } refreshPolicy = RefreshPolicy.readFrom(in); timeout = in.readTimeValue(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { - this.preferV2Templates = in.readOptionalBoolean(); - } } public BulkRequest(@Nullable String globalIndex) { @@ -201,16 +196,6 @@ public List> requests() { return this.requests; } - public BulkRequest preferV2Templates(@Nullable Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - - @Nullable - public Boolean preferV2Templates() { - return this.preferV2Templates; - } - /** * The number of actions in the bulk request. */ @@ -371,9 +356,6 @@ public void writeTo(StreamOutput out) throws IOException { } refreshPolicy.writeTo(out); out.writeTimeValue(timeout); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { - out.writeOptionalBoolean(preferV2Templates); - } } @Override diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 7c7db11f5e6d6..985381fa414f8 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -165,9 +165,7 @@ protected void doExecute(Task task, BulkRequest bulkRequest, ActionListener() { + createIndex(index, bulkRequest.timeout(), minNodeVersion, new ActionListener<>() { @Override public void onResponse(CreateIndexResponse result) { if (counter.decrementAndGet() == 0) { @@ -273,8 +271,7 @@ public void onFailure(Exception e) { } } - static boolean resolvePipelines(final DocWriteRequest originalRequest, final IndexRequest indexRequest, - final boolean preferV2Templates, final Metadata metadata) { + static boolean resolvePipelines(final DocWriteRequest originalRequest, final IndexRequest indexRequest, final Metadata metadata) { if (indexRequest.isPipelineResolved() == false) { final String requestPipeline = indexRequest.getPipeline(); indexRequest.setPipeline(IngestService.NOOP_PIPELINE_NAME); @@ -314,7 +311,7 @@ static boolean resolvePipelines(final DocWriteRequest originalRequest, final // templates to look for pipelines in either a matching V2 template (which takes // precedence), or if a V2 template does not match, any V1 templates String v2Template = MetadataIndexTemplateService.findV2Template(metadata, indexRequest.index(), false); - if (v2Template != null && preferV2Templates) { + if (v2Template != null) { Settings settings = MetadataIndexTemplateService.resolveSettings(metadata, v2Template); if (defaultPipeline == null && IndexSettings.DEFAULT_PIPELINE.exists(settings)) { defaultPipeline = IndexSettings.DEFAULT_PIPELINE.get(settings); @@ -383,7 +380,6 @@ boolean shouldAutoCreate(String index, ClusterState state) { } void createIndex(String index, - Boolean preferV2Templates, TimeValue timeout, Version minNodeVersion, ActionListener listener) { @@ -391,7 +387,6 @@ void createIndex(String index, createIndexRequest.index(index); createIndexRequest.cause("auto(bulk api)"); createIndexRequest.masterNodeTimeout(timeout); - createIndexRequest.preferV2Templates(preferV2Templates); if (minNodeVersion.onOrAfter(Version.V_7_8_0)) { client.execute(AutoCreateAction.INSTANCE, createIndexRequest, listener); } else { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportSingleItemBulkWriteAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportSingleItemBulkWriteAction.java index 60f144f5ead68..c080006b19d77 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportSingleItemBulkWriteAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportSingleItemBulkWriteAction.java @@ -22,7 +22,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.WriteRequest; @@ -73,9 +72,6 @@ public static BulkRequest toSingleItemBulkRequest(ReplicatedWriteRequest requ bulkRequest.setRefreshPolicy(request.getRefreshPolicy()); bulkRequest.timeout(request.timeout()); bulkRequest.waitForActiveShards(request.waitForActiveShards()); - if (request instanceof IndexRequest) { - bulkRequest.preferV2Templates(((IndexRequest) request).preferV2Templates()); - } request.setRefreshPolicy(WriteRequest.RefreshPolicy.NONE); return bulkRequest; } diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 56e6bcb49a69a..635ef118d1a32 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -114,7 +114,6 @@ public class IndexRequest extends ReplicatedWriteRequest implement private boolean isRetry = false; private long ifSeqNo = UNASSIGNED_SEQ_NO; private long ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM; - private Boolean preferV2Templates; public IndexRequest(StreamInput in) throws IOException { super(in); @@ -144,9 +143,6 @@ public IndexRequest(StreamInput in) throws IOException { } ifSeqNo = in.readZLong(); ifPrimaryTerm = in.readVLong(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { - this.preferV2Templates = in.readOptionalBoolean(); - } } public IndexRequest() { @@ -561,16 +557,6 @@ public long ifSeqNo() { return ifSeqNo; } - public IndexRequest preferV2Templates(@Nullable Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - - @Nullable - public Boolean preferV2Templates() { - return this.preferV2Templates; - } - /** * If set, only perform this indexing request if the document was last modification was assigned this primary term. * @@ -652,9 +638,6 @@ public void writeTo(StreamOutput out) throws IOException { } out.writeZLong(ifSeqNo); out.writeVLong(ifPrimaryTerm); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { - out.writeOptionalBoolean(preferV2Templates); - } } @Override diff --git a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 4204840d20f32..5b7f20f7485e0 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -120,7 +120,6 @@ protected void doExecute(Task task, final UpdateRequest request, final ActionLis client.admin().indices().create(new CreateIndexRequest() .index(request.index()) .cause("auto(update api)") - .preferV2Templates(request.preferV2Templates()) .masterNodeTimeout(request.timeout()), new ActionListener() { @Override public void onResponse(CreateIndexResponse result) { diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index d9ee2a11593b2..9847ed74112e9 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -120,7 +120,6 @@ public class UpdateRequest extends InstanceShardOperationRequest private boolean scriptedUpsert = false; private boolean docAsUpsert = false; private boolean detectNoop = true; - private Boolean preferV2Templates; @Nullable private IndexRequest doc; @@ -153,9 +152,6 @@ public UpdateRequest(StreamInput in) throws IOException { ifPrimaryTerm = in.readVLong(); detectNoop = in.readBoolean(); scriptedUpsert = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { - preferV2Templates = in.readOptionalBoolean(); - } } public UpdateRequest(String index, String id) { @@ -804,16 +800,6 @@ public UpdateRequest scriptedUpsert(boolean scriptedUpsert) { return this; } - @Nullable - public Boolean preferV2Templates() { - return this.preferV2Templates; - } - - public UpdateRequest preferV2Templates(@Nullable Boolean preferV2Templates) { - this.preferV2Templates = preferV2Templates; - return this; - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); @@ -855,9 +841,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(ifPrimaryTerm); out.writeBoolean(detectNoop); out.writeBoolean(scriptedUpsert); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { - out.writeOptionalBoolean(preferV2Templates); - } } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 77f083021f6a9..bee1589170cd6 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -246,11 +246,6 @@ public Iterator> settings() { Setting.simpleString(key, value -> IP_VALIDATOR.accept(key, value), Property.Dynamic, Property.IndexScope)); public static final Setting.AffixSetting INDEX_ROUTING_INITIAL_RECOVERY_GROUP_SETTING = Setting.prefixKeySetting("index.routing.allocation.initial_recovery.", key -> Setting.simpleString(key)); - // this is only setable internally not a registered setting!! - public static final String PREFER_V2_TEMPLATES_FLAG = "prefer_v2_templates"; - public static final String SETTING_PREFER_V2_TEMPLATES = "index." + PREFER_V2_TEMPLATES_FLAG; - public static final Setting PREFER_V2_TEMPLATES_SETTING = Setting.boolSetting(SETTING_PREFER_V2_TEMPLATES, true, - Property.Dynamic, Property.IndexScope); /** * The number of active shard copies to check for before proceeding with a write operation. diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java index 0f734a5aee9cc..ea45338be2908 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java @@ -330,19 +330,14 @@ public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateInd // Check to see if a v2 template matched final String v2Template = MetadataIndexTemplateService.findV2Template(currentState.metadata(), request.index(), isHiddenFromRequest == null ? false : isHiddenFromRequest); - final boolean preferV2Templates = resolvePreferV2Templates(request); - if (v2Template != null && preferV2Templates) { + if (v2Template != null) { // If a v2 template was found, it takes precedence over all v1 templates, so create // the index using that template and the request's specified settings return applyCreateIndexRequestWithV2Template(currentState, request, silent, v2Template, metadataTransformer); } else { - if (v2Template != null) { - logger.debug("ignoring matching index template [{}] as [prefer_v2_templates] is set to false", v2Template); - } - // A v2 template wasn't found (or is not preferred), check the v1 templates, in the - // event no templates are found creation still works using the request's specified - // index settings + // A v2 template wasn't found, check the v1 templates, in the event no templates are + // found creation still works using the request's specified index settings final List v1Templates = MetadataIndexTemplateService.findV1Templates(currentState.metadata(), request.index(), isHiddenFromRequest); @@ -357,11 +352,6 @@ public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateInd } } - private static boolean resolvePreferV2Templates(CreateIndexClusterStateUpdateRequest request) { - return request.preferV2Templates() == null ? - IndexMetadata.PREFER_V2_TEMPLATES_SETTING.get(request.settings()) : request.preferV2Templates(); - } - public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request, boolean silent) throws Exception { return applyCreateIndexRequest(currentState, request, silent, null); @@ -430,8 +420,7 @@ private ClusterState applyCreateIndexWithTemporaryService(final ClusterState cur private IndexMetadata buildAndValidateTemporaryIndexMetadata(final ClusterState currentState, final Settings aggregatedIndexSettings, final CreateIndexClusterStateUpdateRequest request, - final int routingNumShards, - final boolean preferV2Templates) { + final int routingNumShards) { final boolean isHiddenAfterTemplates = IndexMetadata.INDEX_HIDDEN_SETTING.get(aggregatedIndexSettings); validateDotIndex(request.index(), currentState, isHiddenAfterTemplates); @@ -439,7 +428,6 @@ private IndexMetadata buildAndValidateTemporaryIndexMetadata(final ClusterState // remove the setting it's temporary and is only relevant once we create the index final Settings.Builder settingsBuilder = Settings.builder().put(aggregatedIndexSettings); settingsBuilder.remove(IndexMetadata.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.getKey()); - settingsBuilder.put(IndexMetadata.PREFER_V2_TEMPLATES_SETTING.getKey(), preferV2Templates); final Settings indexSettings = settingsBuilder.build(); final IndexMetadata.Builder tmpImdBuilder = IndexMetadata.builder(request.index()); @@ -470,8 +458,7 @@ private ClusterState applyCreateIndexRequestWithV1Templates(final ClusterState c aggregateIndexSettings(currentState, request, MetadataIndexTemplateService.resolveSettings(templates), mappings, null, settings, indexScopedSettings); int routingNumShards = getIndexNumberOfRoutingShards(aggregatedIndexSettings, null); - IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards, - resolvePreferV2Templates(request)); + IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards); return applyCreateIndexWithTemporaryService(currentState, request, silent, null, tmpImd, mappings, indexService -> resolveAndValidateAliases(request.index(), request.aliases(), @@ -497,8 +484,7 @@ private ClusterState applyCreateIndexRequestWithV2Template(final ClusterState cu MetadataIndexTemplateService.resolveSettings(currentState.metadata(), templateName), mappings, null, settings, indexScopedSettings); int routingNumShards = getIndexNumberOfRoutingShards(aggregatedIndexSettings, null); - IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards, - resolvePreferV2Templates(request)); + IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards); return applyCreateIndexWithTemporaryService(currentState, request, silent, null, tmpImd, mappings, indexService -> resolveAndValidateAliases(request.index(), request.aliases(), @@ -531,8 +517,7 @@ private ClusterState applyCreateIndexRequestWithExistingMetadata(final ClusterSt final Settings aggregatedIndexSettings = aggregateIndexSettings(currentState, request, Settings.EMPTY, mappings, sourceMetadata, settings, indexScopedSettings); final int routingNumShards = getIndexNumberOfRoutingShards(aggregatedIndexSettings, sourceMetadata); - IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards, - IndexMetadata.PREFER_V2_TEMPLATES_SETTING.get(sourceMetadata.getSettings())); + IndexMetadata tmpImd = buildAndValidateTemporaryIndexMetadata(currentState, aggregatedIndexSettings, request, routingNumShards); return applyCreateIndexWithTemporaryService(currentState, request, silent, sourceMetadata, tmpImd, mappings, indexService -> resolveAndValidateAliases(request.index(), request.aliases(), Collections.emptyList(), diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java index 0a3bd99b3b4ee..96e5c31c1baa9 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java @@ -80,7 +80,6 @@ public final class IndexScopedSettings extends AbstractScopedSettings { IndexMetadata.INDEX_DATA_PATH_SETTING, IndexMetadata.INDEX_HIDDEN_SETTING, IndexMetadata.INDEX_FORMAT_SETTING, - IndexMetadata.PREFER_V2_TEMPLATES_SETTING, SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG_SETTING, SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_WARN_SETTING, SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_INFO_SETTING, diff --git a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index 4f333474bcdf4..9ed9396942a7b 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -19,12 +19,10 @@ package org.elasticsearch.index.reindex; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -71,8 +69,6 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest sourceAsMap = XContentHelper.convertToMap(request.requiredContent(), false, diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java index 878343a3109cb..ad41baaf99c6a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java @@ -54,7 +54,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC rolloverIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", rolloverIndexRequest.masterNodeTimeout())); rolloverIndexRequest.getCreateIndexRequest().waitForActiveShards( ActiveShardCount.parseString(request.param("wait_for_active_shards"))); - rolloverIndexRequest.getCreateIndexRequest().preferV2Templates(RestCreateIndexAction.preferV2Templates(request)); return channel -> client.admin().indices().rolloverIndex(rolloverIndexRequest, new RestToXContentListener<>(channel)); } } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java index bf35bb1e28dcc..ffe21bce355a4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java @@ -28,7 +28,6 @@ import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestStatusToXContentListener; -import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -83,7 +82,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC bulkRequest.setRefreshPolicy(request.param("refresh")); bulkRequest.add(request.requiredContent(), defaultIndex, defaultRouting, defaultFetchSourceContext, defaultPipeline, allowExplicitIndex, request.getXContentType()); - bulkRequest.preferV2Templates(RestCreateIndexAction.preferV2Templates(request)); return channel -> client.bulk(bulkRequest, new RestStatusToXContentListener<>(channel)); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 27d8896678d4b..6c54285d67dad 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -29,7 +29,6 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestActions; import org.elasticsearch.rest.action.RestStatusToXContentListener; -import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction; import java.io.IOException; import java.util.List; @@ -123,7 +122,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC indexRequest.versionType(VersionType.fromString(request.param("version_type"), indexRequest.versionType())); indexRequest.setIfSeqNo(request.paramAsLong("if_seq_no", indexRequest.ifSeqNo())); indexRequest.setIfPrimaryTerm(request.paramAsLong("if_primary_term", indexRequest.ifPrimaryTerm())); - indexRequest.preferV2Templates(RestCreateIndexAction.preferV2Templates(request)); String sOpType = request.param("op_type"); String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards != null) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java index facee1a96a817..af451c02ecc58 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java @@ -29,7 +29,6 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestActions; import org.elasticsearch.rest.action.RestStatusToXContentListener; -import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -55,7 +54,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC updateRequest.routing(request.param("routing")); updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout())); updateRequest.setRefreshPolicy(request.param("refresh")); - updateRequest.preferV2Templates(RestCreateIndexAction.preferV2Templates(request)); String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards != null) { updateRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java index 9b98bcf08cb7f..e99d483787db3 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java @@ -138,8 +138,7 @@ boolean shouldAutoCreate(String index, ClusterState state) { } @Override - void createIndex(String index, Boolean preferV2Templates, - TimeValue timeout, Version minNodeVersion, ActionListener listener) { + void createIndex(String index, TimeValue timeout, Version minNodeVersion, ActionListener listener) { // If we try to create an index just immediately assume it worked listener.onResponse(new CreateIndexResponse(true, true, index) {}); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java index 85f541711ccb2..ec9276e86b5b0 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java @@ -158,9 +158,7 @@ void executeBulk(Task task, final BulkRequest bulkRequest, final long startTimeN } @Override - void createIndex(String index, Boolean preferV2Templates, - TimeValue timeout, Version minNodeVersion, - ActionListener listener) { + void createIndex(String index, TimeValue timeout, Version minNodeVersion, ActionListener listener) { indexCreated = true; listener.onResponse(null); } @@ -593,7 +591,6 @@ public void testFindDefaultPipelineFromV2TemplateMatch() { when(state.getMetadata()).thenReturn(metadata); IndexRequest indexRequest = new IndexRequest("missing_index").id("id"); - indexRequest.preferV2Templates(true); indexRequest.source(Collections.emptyMap()); AtomicBoolean responseCalled = new AtomicBoolean(false); AtomicBoolean failureCalled = new AtomicBoolean(false); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java index d524f7b0b5f17..4af4cc13ac0ee 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java @@ -84,8 +84,7 @@ protected boolean needToCheck() { } @Override - void createIndex(String index, Boolean preferV2Templates, - TimeValue timeout, Version minNodeVersion, ActionListener listener) { + void createIndex(String index, TimeValue timeout, Version minNodeVersion, ActionListener listener) { indexCreated = true; listener.onResponse(null); } @@ -181,14 +180,14 @@ public void testResolveRequiredOrDefaultPipelineDefaultPipeline() { // index name matches with IDM: IndexRequest indexRequest = new IndexRequest("idx"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("default-pipeline")); // alias name matches with IDM: indexRequest = new IndexRequest("alias"); - result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("default-pipeline")); @@ -199,7 +198,7 @@ public void testResolveRequiredOrDefaultPipelineDefaultPipeline() { .settings(settings(Version.CURRENT).put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default-pipeline")); metadata = Metadata.builder().put(templateBuilder).build(); indexRequest = new IndexRequest("idx"); - result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("default-pipeline")); @@ -215,7 +214,7 @@ public void testResolveFinalPipeline() { // index name matches with IDM: IndexRequest indexRequest = new IndexRequest("idx"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("_none")); @@ -223,7 +222,7 @@ public void testResolveFinalPipeline() { // alias name matches with IDM: indexRequest = new IndexRequest("alias"); - result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("_none")); @@ -235,7 +234,7 @@ public void testResolveFinalPipeline() { .settings(settings(Version.CURRENT).put(IndexSettings.FINAL_PIPELINE.getKey(), "final-pipeline")); metadata = Metadata.builder().put(templateBuilder).build(); indexRequest = new IndexRequest("idx"); - result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("_none")); @@ -247,7 +246,7 @@ public void testResolveRequestOrDefaultPipelineAndFinalPipeline() { { Metadata metadata = Metadata.builder().build(); IndexRequest indexRequest = new IndexRequest("idx"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(false)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo(IngestService.NOOP_PIPELINE_NAME)); @@ -257,7 +256,7 @@ public void testResolveRequestOrDefaultPipelineAndFinalPipeline() { { Metadata metadata = Metadata.builder().build(); IndexRequest indexRequest = new IndexRequest("idx").setPipeline("request-pipeline"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("request-pipeline")); @@ -271,7 +270,7 @@ public void testResolveRequestOrDefaultPipelineAndFinalPipeline() { .numberOfReplicas(0); Metadata metadata = Metadata.builder().put(builder).build(); IndexRequest indexRequest = new IndexRequest("idx").setPipeline("request-pipeline"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("request-pipeline")); @@ -285,7 +284,7 @@ public void testResolveRequestOrDefaultPipelineAndFinalPipeline() { .numberOfReplicas(0); Metadata metadata = Metadata.builder().put(builder).build(); IndexRequest indexRequest = new IndexRequest("idx").setPipeline("request-pipeline"); - boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, false, metadata); + boolean result = TransportBulkAction.resolvePipelines(indexRequest, indexRequest, metadata); assertThat(result, is(true)); assertThat(indexRequest.isPipelineResolved(), is(true)); assertThat(indexRequest.getPipeline(), equalTo("request-pipeline")); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java index 1ad13b4209b0c..0bf78fd9bca36 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java @@ -365,7 +365,6 @@ static String[] extractLeaderShardHistoryUUIDs(Map ccrIndexMetad IndexMetadata.INDEX_PRIORITY_SETTING, IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS, IndexMetadata.INDEX_HIDDEN_SETTING, - IndexMetadata.PREFER_V2_TEMPLATES_SETTING, EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING, EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING, ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING,