diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java index cae2042f52f..67c8fe44b4b 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java @@ -231,9 +231,7 @@ public class IndexTemplateMetaData extends AbstractDiffable aliases = Sets.newHashSet(indexSettings.getSettings().getAsArray(analyzerAliasKey)); - for (String alias : aliases) { - if (analyzerAliases.putIfAbsent(alias, analyzer) != null) { - throw new IllegalStateException("alias [" + alias + "] is already used by [" + analyzerAliases.get(alias).name() + "]"); - } - } + throw new IllegalArgumentException("setting [" + analyzerAliasKey + "] is not supported"); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java b/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java index 8f3634e0132..8da1915b8ca 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java @@ -186,7 +186,7 @@ public class DynamicTemplate implements ToXContentObject { matchPattern = entry.getValue().toString(); } else if ("mapping".equals(propName)) { mapping = (Map) entry.getValue(); - } else if (indexVersionCreated.onOrAfter(Version.V_5_0_0_alpha1)) { + } else { // unknown parameters were ignored before but still carried through serialization // so we need to ignore them at parsing time for old indices throw new IllegalArgumentException("Illegal dynamic template parameter: [" + propName + "]"); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index c2af9f715dd..6985858dfe8 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -212,19 +212,11 @@ public abstract class FieldMapper extends Mapper implements Cloneable { } protected boolean defaultDocValues(Version indexCreated) { - if (indexCreated.onOrAfter(Version.V_5_0_0_alpha1)) { - // add doc values by default to keyword (boolean, numerics, etc.) fields - return fieldType.tokenized() == false; - } else { - return fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE; - } + return fieldType.tokenized() == false; } protected void setupFieldType(BuilderContext context) { fieldType.setName(buildFullName(context)); - if (context.indexCreatedVersion().before(Version.V_5_0_0_alpha1)) { - fieldType.setOmitNorms(fieldType.omitNorms() && fieldType.boost() == 1.0f); - } if (fieldType.indexAnalyzer() == null && fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE) { fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); @@ -247,10 +239,8 @@ public abstract class FieldMapper extends Mapper implements Cloneable { super(simpleName); assert indexSettings != null; this.indexCreatedVersion = Version.indexCreated(indexSettings); - if (indexCreatedVersion.onOrAfter(Version.V_5_0_0_beta1)) { - if (simpleName.isEmpty()) { - throw new IllegalArgumentException("name cannot be empty string"); - } + if (simpleName.isEmpty()) { + throw new IllegalArgumentException("name cannot be empty string"); } fieldType.freeze(); this.fieldType = fieldType; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java index 347ec4d679b..7f3f934419a 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java @@ -77,10 +77,7 @@ public class IndexFieldMapper extends MetadataFieldMapper { public static class TypeParser implements MetadataFieldMapper.TypeParser { @Override public MetadataFieldMapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { - if (parserContext.indexVersionCreated().onOrAfter(Version.V_5_0_0_alpha3)) { - throw new MapperParsingException(NAME + " is not configurable"); - } - return new Builder(parserContext.mapperService().fullName(NAME)); + throw new MapperParsingException(NAME + " is not configurable"); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java index 1d3c4791b65..c4cf0785cb2 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java @@ -321,11 +321,8 @@ public class ObjectMapper extends Mapper implements Cloneable { Boolean includeInAll, Map mappers, Settings settings) { super(name); assert settings != null; - Version indexCreatedVersion = Version.indexCreated(settings); - if (indexCreatedVersion.onOrAfter(Version.V_5_0_0_beta1)) { - if (name.isEmpty()) { - throw new IllegalArgumentException("name cannot be empty string"); - } + if (name.isEmpty()) { + throw new IllegalArgumentException("name cannot be empty string"); } this.fullPath = fullPath; this.enabled = enabled; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index 5e1b6843940..fc177e45d5c 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -116,9 +116,6 @@ public class SourceFieldMapper extends MetadataFieldMapper { if (fieldName.equals("enabled")) { builder.enabled(TypeParsers.nodeBooleanValue(name, "enabled", fieldNode, parserContext)); iterator.remove(); - } else if ("format".equals(fieldName) && parserContext.indexVersionCreated().before(Version.V_5_0_0_alpha1)) { - // ignore on old indices, reject on and after 5.0 - iterator.remove(); } else if (fieldName.equals("includes")) { List values = (List) fieldNode; String[] includes = new String[values.size()]; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/TermBasedFieldType.java b/core/src/main/java/org/elasticsearch/index/mapper/TermBasedFieldType.java index 89b09cc068e..ee398739956 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/TermBasedFieldType.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/TermBasedFieldType.java @@ -27,7 +27,6 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermInSetQuery; import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.index.query.QueryShardContext; @@ -51,12 +50,11 @@ abstract class TermBasedFieldType extends MappedFieldType { @Override public Query termQuery(Object value, QueryShardContext context) { failIfNotIndexed(); - TermQuery query = new TermQuery(new Term(name(), indexedValueForSearch(value))); - if (boost() == 1f || - (context != null && context.indexVersionCreated().before(Version.V_5_0_0_alpha1))) { - return query; + Query query = new TermQuery(new Term(name(), indexedValueForSearch(value))); + if (boost() != 1f) { + query = new BoostQuery(query, boost()); } - return new BoostQuery(query, boost()); + return query; } @Override diff --git a/core/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java b/core/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java index 18928246772..07c7af20d3b 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java @@ -35,11 +35,9 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import static org.elasticsearch.common.xcontent.support.XContentMapValues.isArray; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeFloatValue; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeMapValue; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringValue; public class TypeParsers { @@ -158,37 +156,9 @@ public class TypeParsers { } } - public static boolean parseNorms(FieldMapper.Builder builder, String fieldName, String propName, Object propNode, + public static void parseNorms(FieldMapper.Builder builder, String fieldName, Object propNode, Mapper.TypeParser.ParserContext parserContext) { - if (propName.equals("norms")) { - if (propNode instanceof Map) { - final Map properties = nodeMapValue(propNode, "norms"); - for (Iterator> propsIterator = properties.entrySet().iterator(); propsIterator.hasNext(); ) { - Entry entry2 = propsIterator.next(); - final String propName2 = entry2.getKey(); - final Object propNode2 = entry2.getValue(); - if (propName2.equals("enabled")) { - builder.omitNorms(nodeBooleanValue(fieldName, "enabled", propNode2, parserContext) == false); - propsIterator.remove(); - } else if (propName2.equals("loading")) { - // ignore for bw compat - propsIterator.remove(); - } - } - DocumentMapperParser.checkNoRemainingFields(propName, properties, parserContext.indexVersionCreated()); - DEPRECATION_LOGGER.deprecated("The [norms{enabled:true/false}] way of specifying norms is deprecated, please use " + - "[norms:true/false] instead"); - } else { - builder.omitNorms(nodeBooleanValue(fieldName,"norms", propNode, parserContext) == false); - } - return true; - } else if (propName.equals("omit_norms")) { - builder.omitNorms(nodeBooleanValue(fieldName,"norms", propNode, parserContext)); - DEPRECATION_LOGGER.deprecated("[omit_norms] is deprecated, please use [norms] instead with the opposite boolean value"); - return true; - } else { - return false; - } + builder.omitNorms(nodeBooleanValue(fieldName, "norms", propNode, parserContext) == false); } /** @@ -203,7 +173,8 @@ public class TypeParsers { Map.Entry entry = iterator.next(); final String propName = entry.getKey(); final Object propNode = entry.getValue(); - if (parseNorms(builder, name, propName, propNode, parserContext)) { + if ("norms".equals(propName)) { + parseNorms(builder, name, propNode, parserContext); iterator.remove(); } } @@ -237,9 +208,6 @@ public class TypeParsers { } else if (propName.equals("boost")) { builder.boost(nodeFloatValue(propNode)); iterator.remove(); - } else if (parserContext.indexVersionCreated().before(Version.V_5_0_0_alpha1) - && parseNorms(builder, name, propName, propNode, parserContext)) { - iterator.remove(); } else if (propName.equals("index_options")) { builder.indexOptions(nodeIndexOptionValue(propNode)); iterator.remove(); @@ -259,11 +227,6 @@ public class TypeParsers { SimilarityProvider similarityProvider = resolveSimilarity(parserContext, name, propNode.toString()); builder.similarity(similarityProvider); iterator.remove(); - } else if (propName.equals("fielddata") - && propNode instanceof Map - && parserContext.indexVersionCreated().before(Version.V_5_0_0_alpha1)) { - // ignore for bw compat - iterator.remove(); } else if (parseMultiField(builder, name, parserContext, propName, propNode)) { iterator.remove(); } else if (propName.equals("copy_to")) { @@ -387,10 +350,6 @@ public class TypeParsers { } private static SimilarityProvider resolveSimilarity(Mapper.TypeParser.ParserContext parserContext, String name, String value) { - if (parserContext.indexVersionCreated().before(Version.V_5_0_0_alpha1) && "default".equals(value)) { - // "default" similarity has been renamed into "classic" in 3.x. - value = "classic"; - } SimilarityProvider similarityProvider = parserContext.getSimilarity(value); if (similarityProvider == null) { throw new MapperParsingException("Unknown Similarity type [" + value + "] for field [" + name + "]"); diff --git a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index 4d8c9359a81..5c4a425828f 100644 --- a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -79,8 +79,7 @@ public final class SimilarityService extends AbstractIndexComponent { Map similaritySettings = this.indexSettings.getSettings().getGroups(IndexModule.SIMILARITY_SETTINGS_PREFIX); for (Map.Entry entry : similaritySettings.entrySet()) { String name = entry.getKey(); - // Starting with v5.0 indices, it should no longer be possible to redefine built-in similarities - if(BUILT_IN.containsKey(name) && indexSettings.getIndexVersionCreated().onOrAfter(Version.V_5_0_0_alpha1)) { + if (BUILT_IN.containsKey(name)) { throw new IllegalArgumentException("Cannot redefine built-in Similarity [" + name + "]"); } Settings providerSettings = entry.getValue(); @@ -97,10 +96,6 @@ public final class SimilarityService extends AbstractIndexComponent { Map providerMapping = addSimilarities(similaritySettings, indexSettings.getSettings(), scriptService, DEFAULTS); for (Map.Entry entry : providerMapping.entrySet()) { - // Avoid overwriting custom providers for indices older that v5.0 - if (providers.containsKey(entry.getKey()) && indexSettings.getIndexVersionCreated().before(Version.V_5_0_0_alpha1)) { - continue; - } providers.put(entry.getKey(), entry.getValue()); } this.similarities = providers;