Remove bw compat from murmur3 mapper
This commit is contained in:
parent
7e4c4cd8d9
commit
f96900013c
|
@ -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);
|
||||
|
|
|
@ -44,11 +44,6 @@ import java.util.Collections;
|
|||
|
||||
public class Murmur3FieldMapperTests extends ESSingleNodeTestCase {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> 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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue