diff --git a/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperMergeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperMergeTests.java index 0737dcb7cb5d2..5fefa915095ea 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperMergeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/ObjectMapperMergeTests.java @@ -310,7 +310,21 @@ public void testMergeWithLimitRuntimeField() { assertEquals(3, mergedAdd0.mapperSize()); assertEquals(4, mergedAdd1.mapperSize()); } + public void testMergedMappingSubobjectsFalse() { + ObjectMapper mergeInto = new ObjectMapper.Builder("parent", Explicit.IMPLICIT_FALSE) + .build(MapperBuilderContext.root(false, false)); + RootObjectMapper mergeWith= new RootObjectMapper.Builder("parent", Explicit.IMPLICIT_TRUE).add( + new ObjectMapper.Builder("child", Explicit.IMPLICIT_TRUE).add( + new KeywordFieldMapper.Builder("grandchild", IndexVersion.current()) + ) + ).build(MapperBuilderContext.root(false, false)); + ObjectMapper merged = mergeInto.merge(mergeWith, MapperMergeContext.root(false, false, Long.MAX_VALUE)); + ObjectMapper child = (ObjectMapper) merged.getMapper("child"); + KeywordFieldMapper keywordFieldMapper = (KeywordFieldMapper) child.getMapper("grandchild"); + assertNull(child); + assertNull(keywordFieldMapper); + } private static RootObjectMapper createRootSubobjectFalseLeafWithDots() { FieldMapper.Builder fieldBuilder = new KeywordFieldMapper.Builder("host.name", IndexVersion.current()); FieldMapper fieldMapper = fieldBuilder.build(MapperBuilderContext.root(false, false)); @@ -352,4 +366,5 @@ private TextFieldMapper.Builder createTextKeywordMultiField(String name, String builder.multiFieldsBuilder.add(new KeywordFieldMapper.Builder(multiFieldName, IndexVersion.current())); return builder; } + }