fix field names to be disabled again pre 1.3
This commit is contained in:
parent
b0466bbacd
commit
9d57818cee
|
@ -187,6 +187,11 @@ public class FieldNamesFieldMapper extends AbstractFieldMapper implements RootMa
|
||||||
super(fieldType, false, fieldDataSettings, indexSettings);
|
super(fieldType, false, fieldDataSettings, indexSettings);
|
||||||
this.defaultFieldType = Defaults.FIELD_TYPE;
|
this.defaultFieldType = Defaults.FIELD_TYPE;
|
||||||
this.pre13Index = Version.indexCreated(indexSettings).before(Version.V_1_3_0);
|
this.pre13Index = Version.indexCreated(indexSettings).before(Version.V_1_3_0);
|
||||||
|
if (this.pre13Index) {
|
||||||
|
this.fieldType = this.fieldType.clone();
|
||||||
|
fieldType().setEnabled(false);
|
||||||
|
this.fieldType.freeze();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -194,10 +199,6 @@ public class FieldNamesFieldMapper extends AbstractFieldMapper implements RootMa
|
||||||
return (FieldNamesFieldType)fieldType;
|
return (FieldNamesFieldType)fieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabled() {
|
|
||||||
return pre13Index == false && fieldType().isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MappedFieldType defaultFieldType() {
|
public MappedFieldType defaultFieldType() {
|
||||||
return defaultFieldType;
|
return defaultFieldType;
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class FieldNamesFieldMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
||||||
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
||||||
assertTrue(fieldNamesMapper.enabled());
|
assertTrue(fieldNamesMapper.fieldType().isEnabled());
|
||||||
|
|
||||||
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -115,7 +115,7 @@ public class FieldNamesFieldMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
||||||
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
||||||
assertFalse(fieldNamesMapper.enabled());
|
assertFalse(fieldNamesMapper.fieldType().isEnabled());
|
||||||
|
|
||||||
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -131,7 +131,7 @@ public class FieldNamesFieldMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_2_4.id).build();
|
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_2_4.id).build();
|
||||||
DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse(mapping);
|
DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse(mapping);
|
||||||
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
||||||
assertFalse(fieldNamesMapper.enabled());
|
assertFalse(fieldNamesMapper.fieldType().isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisablingBackcompat() throws Exception {
|
public void testDisablingBackcompat() throws Exception {
|
||||||
|
@ -143,7 +143,7 @@ public class FieldNamesFieldMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
|
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
|
||||||
DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse(mapping);
|
DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse(mapping);
|
||||||
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
FieldNamesFieldMapper fieldNamesMapper = docMapper.rootMapper(FieldNamesFieldMapper.class);
|
||||||
assertFalse(fieldNamesMapper.enabled());
|
assertFalse(fieldNamesMapper.fieldType().isEnabled());
|
||||||
|
|
||||||
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -177,10 +177,10 @@ public class FieldNamesFieldMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
DocumentMapper mapperEnabled = parser.parse(enabledMapping);
|
DocumentMapper mapperEnabled = parser.parse(enabledMapping);
|
||||||
DocumentMapper mapperDisabled = parser.parse(disabledMapping);
|
DocumentMapper mapperDisabled = parser.parse(disabledMapping);
|
||||||
mapperEnabled.merge(mapperDisabled.mapping(), false);
|
mapperEnabled.merge(mapperDisabled.mapping(), false);
|
||||||
assertFalse(mapperEnabled.rootMapper(FieldNamesFieldMapper.class).enabled());
|
assertFalse(mapperEnabled.rootMapper(FieldNamesFieldMapper.class).fieldType().isEnabled());
|
||||||
|
|
||||||
mapperEnabled = parser.parse(enabledMapping);
|
mapperEnabled = parser.parse(enabledMapping);
|
||||||
mapperDisabled.merge(mapperEnabled.mapping(), false);
|
mapperDisabled.merge(mapperEnabled.mapping(), false);
|
||||||
assertTrue(mapperEnabled.rootMapper(FieldNamesFieldMapper.class).enabled());
|
assertTrue(mapperEnabled.rootMapper(FieldNamesFieldMapper.class).fieldType().isEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue