Skip to content

Commit

Permalink
Remove "template" field in IndexTemplateMetaData (#42099)
Browse files Browse the repository at this point in the history
Remove "template" field from XContent parsing in IndexTemplateMetaData
  • Loading branch information
PnPie authored and hub-cap committed Jun 3, 2019
1 parent ec427ff commit 561efa7
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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.cluster.AbstractDiffable;
import org.elasticsearch.cluster.Diff;
Expand All @@ -32,7 +31,6 @@
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;
Expand All @@ -52,8 +50,6 @@

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;
Expand Down Expand Up @@ -97,7 +93,7 @@ public IndexTemplateMetaData(String name, int order, Integer version,
this.name = name;
this.order = order;
this.version = version;
this.patterns= patterns;
this.patterns = patterns;
this.settings = settings;
this.mappings = mappings;
this.aliases = aliases;
Expand Down Expand Up @@ -227,7 +223,7 @@ public void writeTo(StreamOutput out) throws IOException {
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;

Expand Down Expand Up @@ -487,11 +483,7 @@ public static IndexTemplateMetaData fromXContent(XContentParser parser, String t
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());
Expand Down

0 comments on commit 561efa7

Please sign in to comment.