diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java index 2d03a08d2d42c..c5be421ed6fb4 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java @@ -278,18 +278,14 @@ public PutIndexTemplateRequest source(Map templateSource) { Map source = templateSource; for (Map.Entry entry : source.entrySet()) { String name = entry.getKey(); - if (name.equals("template")) { - if(entry.getValue() instanceof String) { - patterns(Collections.singletonList((String) entry.getValue())); - } - } else if (name.equals("index_patterns")) { + if (name.equals("index_patterns")) { if(entry.getValue() instanceof String) { patterns(Collections.singletonList((String) entry.getValue())); } else if (entry.getValue() instanceof List) { List elements = ((List) entry.getValue()).stream().map(Object::toString).collect(Collectors.toList()); patterns(elements); } else { - throw new IllegalArgumentException("Malformed [template] value, should be a string or a list of strings"); + throw new IllegalArgumentException("Malformed [index_patterns] value, should be a string or a list of strings"); } } else if (name.equals("order")) { order(XContentMapValues.nodeIntegerValue(entry.getValue(), order())); diff --git a/docs/reference/migration/migrate_8_0/indices.asciidoc b/docs/reference/migration/migrate_8_0/indices.asciidoc index 49a72352e6354..5b1d5a10df090 100644 --- a/docs/reference/migration/migrate_8_0/indices.asciidoc +++ b/docs/reference/migration/migrate_8_0/indices.asciidoc @@ -20,3 +20,10 @@ The `index.force_memory_term_dictionary` setting was introduced in 7.0 as a temporary measure to allow users to opt-out of the optimization that leaves the term dictionary on disk when appropriate. This optimization is now mandatory and the setting is removed. + +[float] +==== Remove support for `template` in put index template requests + +In 6.0, we deprecated the `template` field in put index template requests +in favor of using `index_patterns`. Support for the `template` field is now +removed in 8.0. diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 0703d567fd024..d1c4c70961136 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -323,14 +323,8 @@ public PutIndexTemplateRequest source(Map templateSource) { Map source = templateSource; for (Map.Entry entry : source.entrySet()) { String name = entry.getKey(); - if (name.equals("template")) { - // This is needed to allow for bwc (beats, logstash) with pre-5.0 templates (#21009) - if(entry.getValue() instanceof String) { - deprecationLogger.deprecated("Deprecated field [template] used, replaced by [index_patterns]"); - patterns(Collections.singletonList((String) entry.getValue())); - } - } else if (name.equals("index_patterns")) { - if(entry.getValue() instanceof String) { + if (name.equals("index_patterns")) { + if (entry.getValue() instanceof String) { patterns(Collections.singletonList((String) entry.getValue())); } else if (entry.getValue() instanceof List) { List elements = ((List) entry.getValue()).stream().map(Object::toString).collect(Collectors.toList()); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java index 7fe68839d068b..68e62ac3c684f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java @@ -19,11 +19,9 @@ package org.elasticsearch.rest.action.admin.indices; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; @@ -32,14 +30,10 @@ import java.io.IOException; import java.util.Arrays; -import java.util.Collections; import java.util.Map; public class RestPutIndexTemplateAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestPutIndexTemplateAction.class)); - public RestPutIndexTemplateAction(RestController controller) { controller.registerHandler(RestRequest.Method.PUT, "/_template/{name}", this); controller.registerHandler(RestRequest.Method.POST, "/_template/{name}", this); @@ -54,12 +48,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name")); - if (request.hasParam("template")) { - deprecationLogger.deprecated("Deprecated parameter[template] used, replaced by [index_patterns]"); - putRequest.patterns(Collections.singletonList(request.param("template"))); - } else { - putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY))); - } + putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY))); putRequest.order(request.paramAsInt("order", putRequest.order())); putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout())); putRequest.create(request.paramAsBoolean("create", false)); diff --git a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index df30def2d0007..a3c3c1e25001f 100644 --- a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -433,7 +433,7 @@ public void testIndexTemplateWithAliases() throws Exception { public void testIndexTemplateWithAliasesInSource() { client().admin().indices().preparePutTemplate("template_1") .setSource(new BytesArray("{\n" + - " \"template\" : \"*\",\n" + + " \"index_patterns\" : \"*\",\n" + " \"aliases\" : {\n" + " \"my_alias\" : {\n" + " \"filter\" : {\n" +