diff --git a/server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java index 30279f565d55b..870fa3df550ee 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java @@ -43,11 +43,19 @@ Builder includeInRoot(boolean includeInRoot) { return this; } + void includeInRoot(Explicit includeInRoot) { + this.includeInRoot = includeInRoot; + } + Builder includeInParent(boolean includeInParent) { this.includeInParent = new Explicit<>(includeInParent, true); return this; } + void includeInParent(Explicit includeInParent) { + this.includeInParent = includeInParent; + } + @Override public NestedObjectMapper build(ContentPath contentPath) { return new NestedObjectMapper(name, contentPath.pathAsText(name), buildMappers(contentPath), this); @@ -94,6 +102,7 @@ protected static void parseNested(String name, Map node, NestedO private Explicit includeInParent; private final String nestedTypePath; private final Query nestedTypeFilter; + private final Version indexCreatedVersion; NestedObjectMapper( String name, @@ -110,6 +119,7 @@ protected static void parseNested(String name, Map node, NestedO this.nestedTypeFilter = NestedPathFieldMapper.filter(builder.indexCreatedVersion, nestedTypePath); this.includeInParent = builder.includeInParent; this.includeInRoot = builder.includeInRoot; + this.indexCreatedVersion = builder.indexCreatedVersion; } public Query nestedTypeFilter() { @@ -184,9 +194,11 @@ public ObjectMapper merge(Mapper mergeWith, MapperService.MergeReason reason) { if (includeInParent.value() != mergeWithObject.includeInParent.value()) { throw new MapperException("the [include_in_parent] parameter can't be updated on a nested object mapping"); } + builder.includeInParent(includeInParent); if (includeInRoot.value() != mergeWithObject.includeInRoot.value()) { throw new MapperException("the [include_in_root] parameter can't be updated on a nested object mapping"); } + builder.includeInRoot(includeInRoot); } toMerge.doMerge(mergeWithObject, reason); return toMerge;