Skip to content

Commit e4b8474

Browse files
committed
# This is a combination of 4 commits.tree 09bd3af420b9a9e07270415c9f84b7a43bf7af9c
parent 1920f00 author Alan Woodward <[email protected]> 1626700953 +0100 committer Alan Woodward <[email protected]> 1626700953 +0100 Make NestedObjectMapper its own class (elastic#74410) Nested objects are implemented via a Nested class directly on object mappers, even though nested and non-nested objects have quite different semantics. In addition, most call-sites that need to get an object mapper in fact need a nested object mapper. To make it clearer that nested and object mappers are different beasts with different implementations and different requirements, we should split them into different classes. server:test compiles :server:tests pass # This is the commit message elastic#4: fix merge includes
1 parent 1920f00 commit e4b8474

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@ Builder includeInRoot(boolean includeInRoot) {
4343
return this;
4444
}
4545

46+
void includeInRoot(Explicit<Boolean> includeInRoot) {
47+
this.includeInRoot = includeInRoot;
48+
}
49+
4650
Builder includeInParent(boolean includeInParent) {
4751
this.includeInParent = new Explicit<>(includeInParent, true);
4852
return this;
4953
}
5054

55+
void includeInParent(Explicit<Boolean> includeInParent) {
56+
this.includeInParent = includeInParent;
57+
}
58+
5159
@Override
5260
public NestedObjectMapper build(ContentPath contentPath) {
5361
return new NestedObjectMapper(name, contentPath.pathAsText(name), buildMappers(contentPath), this);
@@ -94,6 +102,7 @@ protected static void parseNested(String name, Map<String, Object> node, NestedO
94102
private Explicit<Boolean> includeInParent;
95103
private final String nestedTypePath;
96104
private final Query nestedTypeFilter;
105+
private final Version indexCreatedVersion;
97106

98107
NestedObjectMapper(
99108
String name,
@@ -110,6 +119,7 @@ protected static void parseNested(String name, Map<String, Object> node, NestedO
110119
this.nestedTypeFilter = NestedPathFieldMapper.filter(builder.indexCreatedVersion, nestedTypePath);
111120
this.includeInParent = builder.includeInParent;
112121
this.includeInRoot = builder.includeInRoot;
122+
this.indexCreatedVersion = builder.indexCreatedVersion;
113123
}
114124

115125
public Query nestedTypeFilter() {
@@ -184,9 +194,11 @@ public ObjectMapper merge(Mapper mergeWith, MapperService.MergeReason reason) {
184194
if (includeInParent.value() != mergeWithObject.includeInParent.value()) {
185195
throw new MapperException("the [include_in_parent] parameter can't be updated on a nested object mapping");
186196
}
197+
builder.includeInParent(includeInParent);
187198
if (includeInRoot.value() != mergeWithObject.includeInRoot.value()) {
188199
throw new MapperException("the [include_in_root] parameter can't be updated on a nested object mapping");
189200
}
201+
builder.includeInRoot(includeInRoot);
190202
}
191203
toMerge.doMerge(mergeWithObject, reason);
192204
return toMerge;

0 commit comments

Comments
 (0)