Remove "template" field in IndexTemplateMetaData (#42099)

Remove "template" field from XContent parsing in IndexTemplateMetaData
This commit is contained in:
Yu 2019-06-04 00:37:59 +08:00 committed by Michael Basnight
parent 00db9c1a2f
commit 428beabc49
1 changed files with 3 additions and 11 deletions

View File

@ -20,7 +20,6 @@ package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.AbstractDiffable;
@ -33,7 +32,6 @@ import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.ToXContent;
@ -53,8 +51,6 @@ import java.util.Set;
public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaData> {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IndexTemplateMetaData.class));
private final String name;
private final int order;
@ -98,7 +94,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
this.name = name;
this.order = order;
this.version = version;
this.patterns= patterns;
this.patterns = patterns;
this.settings = settings;
this.mappings = mappings;
this.aliases = aliases;
@ -247,7 +243,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
public static class Builder {
private static final Set<String> VALID_FIELDS = Sets.newHashSet(
"template", "order", "mappings", "settings", "index_patterns", "aliases", "version");
"order", "mappings", "settings", "index_patterns", "aliases", "version");
private String name;
@ -507,11 +503,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
builder.patterns(index_patterns);
}
} else if (token.isValue()) {
// Prior to 5.1.0, elasticsearch only supported a single index pattern called `template` (#21009)
if("template".equals(currentFieldName)) {
deprecationLogger.deprecated("Deprecated field [template] used, replaced by [index_patterns]");
builder.patterns(Collections.singletonList(parser.text()));
} else if ("order".equals(currentFieldName)) {
if ("order".equals(currentFieldName)) {
builder.order(parser.intValue());
} else if ("version".equals(currentFieldName)) {
builder.version(parser.intValue());