diff --git a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index c80d17ca81a..85fc6b6bc1a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -532,7 +532,11 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { context.path().remove(); Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "object"); if (builder == null) { - builder = MapperBuilders.object(currentFieldName).enabled(true).dynamic(dynamic).pathType(pathType); + builder = MapperBuilders.object(currentFieldName).enabled(true).pathType(pathType); + // if this is a non root object, then explicitly set the dynamic behavior if set + if (!(this instanceof RootObjectMapper) && this.dynamic != Defaults.DYNAMIC) { + ((Builder) builder).dynamic(this.dynamic); + } } BuilderContext builderContext = new BuilderContext(context.indexSettings(), context.path()); objectMapper = builder.build(builderContext);