Mapping updates on objects should propagate `include_an_all`. #20051
Today you can't update `include_an_all` on an existing object. The bug affects 2.x too.
This commit is contained in:
parent
825edd8dba
commit
8f8ae8f577
|
@ -430,6 +430,7 @@ public class ObjectMapper extends Mapper implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
this.includeInAll = mergeWith.includeInAll;
|
||||
if (mergeWith.dynamic != null) {
|
||||
this.dynamic = mergeWith.dynamic;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,12 @@ import org.elasticsearch.common.compress.CompressedXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MapperService.MergeReason;
|
||||
import org.elasticsearch.index.mapper.ObjectMapper.Dynamic;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class ObjectMapperTests extends ESSingleNodeTestCase {
|
||||
|
@ -155,4 +159,27 @@ public class ObjectMapperTests extends ESSingleNodeTestCase {
|
|||
.string();
|
||||
createIndex("test").mapperService().documentMapperParser().parse("tweet", new CompressedXContent(mapping));
|
||||
}
|
||||
|
||||
public void testMerge() throws IOException {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
MapperService mapperService = createIndex("test").mapperService();
|
||||
DocumentMapper mapper = mapperService.merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false);
|
||||
assertNull(mapper.root().includeInAll());
|
||||
assertNull(mapper.root().dynamic());
|
||||
String update = XContentFactory.jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.field("include_in_all", false)
|
||||
.field("dynamic", "strict")
|
||||
.endObject().endObject().string();
|
||||
mapper = mapperService.merge("type", new CompressedXContent(update), MergeReason.MAPPING_UPDATE, false);
|
||||
assertFalse(mapper.root().includeInAll());
|
||||
assertEquals(Dynamic.STRICT, mapper.root().dynamic());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue