diff --git a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java index ce78c75d783..76ffaa16ae6 100644 --- a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java +++ b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java @@ -72,12 +72,10 @@ public class Murmur3FieldMapper extends LongFieldMapper { @Override protected void setupFieldType(BuilderContext context) { super.setupFieldType(context); - if (context.indexCreatedVersion().onOrAfter(Version.V_2_0_0_beta1)) { - fieldType.setIndexOptions(IndexOptions.NONE); - defaultFieldType.setIndexOptions(IndexOptions.NONE); - fieldType.setHasDocValues(true); - defaultFieldType.setHasDocValues(true); - } + fieldType.setIndexOptions(IndexOptions.NONE); + defaultFieldType.setIndexOptions(IndexOptions.NONE); + fieldType.setHasDocValues(true); + defaultFieldType.setHasDocValues(true); } @Override @@ -97,17 +95,11 @@ public class Murmur3FieldMapper extends LongFieldMapper { Builder builder = new Builder(name); // tweaking these settings is no longer allowed, the entire purpose of murmur3 fields is to store a hash - if (parserContext.indexVersionCreated().onOrAfter(Version.V_2_0_0_beta1)) { - if (node.get("doc_values") != null) { - throw new MapperParsingException("Setting [doc_values] cannot be modified for field [" + name + "]"); - } - if (node.get("index") != null) { - throw new MapperParsingException("Setting [index] cannot be modified for field [" + name + "]"); - } + if (node.get("doc_values") != null) { + throw new MapperParsingException("Setting [doc_values] cannot be modified for field [" + name + "]"); } - - if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) { - builder.indexOptions(IndexOptions.DOCS); + if (node.get("index") != null) { + throw new MapperParsingException("Setting [index] cannot be modified for field [" + name + "]"); } parseNumberField(builder, name, node, parserContext); diff --git a/plugins/mapper-murmur3/src/test/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapperTests.java b/plugins/mapper-murmur3/src/test/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapperTests.java index 072c0db3e59..621ce4b8a1f 100644 --- a/plugins/mapper-murmur3/src/test/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapperTests.java +++ b/plugins/mapper-murmur3/src/test/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapperTests.java @@ -44,11 +44,6 @@ import java.util.Collections; public class Murmur3FieldMapperTests extends ESSingleNodeTestCase { - @Override - protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); - } - MapperRegistry mapperRegistry; IndexService indexService; DocumentMapperParser parser; @@ -131,38 +126,4 @@ public class Murmur3FieldMapperTests extends ESSingleNodeTestCase { assertTrue(e.getMessage().contains("Setting [index] cannot be modified")); } } - - public void testDocValuesSettingBackcompat() throws Exception { - Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build(); - indexService = createIndex("test_bwc", settings); - parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), - indexService.analysisService(), indexService.similarityService(), mapperRegistry, indexService::newQueryShardContext); - String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field") - .field("type", "murmur3") - .field("doc_values", false) - .endObject().endObject().endObject().endObject().string(); - - DocumentMapper docMapper = parser.parse("type", new CompressedXContent(mapping)); - Murmur3FieldMapper mapper = (Murmur3FieldMapper)docMapper.mappers().getMapper("field"); - assertFalse(mapper.fieldType().hasDocValues()); - } - - public void testIndexSettingBackcompat() throws Exception { - Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build(); - indexService = createIndex("test_bwc", settings); - parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), - indexService.analysisService(), indexService.similarityService(), mapperRegistry, indexService::newQueryShardContext); - String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field") - .field("type", "murmur3") - .field("index", "not_analyzed") - .endObject().endObject().endObject().endObject().string(); - - DocumentMapper docMapper = parser.parse("type", new CompressedXContent(mapping)); - Murmur3FieldMapper mapper = (Murmur3FieldMapper)docMapper.mappers().getMapper("field"); - assertEquals(IndexOptions.DOCS, mapper.fieldType().indexOptions()); - } - - // TODO: add more tests }