Skip to content

Commit

Permalink
Fix synthetic source issue with deeply nested ignored source fields (#…
Browse files Browse the repository at this point in the history
…121715) (#121791)

* Fix synthetic source issue with deeply nested ignored source fields

* Update docs/changelog/121715.yaml
  • Loading branch information
lkts authored Feb 5, 2025
1 parent f9e9abd commit 3854eb2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog/121715.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 121715
summary: Fix synthetic source issue with deeply nested ignored source fields
area: Mapping
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ public boolean setIgnoredValues(Map<String, List<IgnoredSourceFieldMapper.NameVa
for (SourceLoader.SyntheticFieldLoader loader : fields) {
ignoredValuesPresent |= loader.setIgnoredValues(objectsWithIgnoredFields);
}
return this.ignoredValues != null;
return ignoredValuesPresent;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,34 @@ public void testStoredArrayWithFlatFields() throws IOException {
{"outer":{"inner":[{"a.b":"a.b","a.c":"a.c"}]}}""", syntheticSource);
}

public void testSingleDeepIgnoredField() throws IOException {
DocumentMapper documentMapper = createSytheticSourceMapperService(mapping(b -> {
b.startObject("top");
b.startObject("properties");
{
b.startObject("level1").startObject("properties");
{
b.startObject("level2").startObject("properties");
{
b.startObject("n")
.field("type", "integer")
.field("doc_values", "false")
.field("synthetic_source_keep", "all")
.endObject();
}
b.endObject().endObject();
}
b.endObject().endObject();
}
b.endObject().endObject();
})).documentMapper();

var syntheticSource = syntheticSource(documentMapper, b -> {
b.startObject("top").startObject("level1").startObject("level2").field("n", 25).endObject().endObject().endObject();
});
assertEquals("{\"top\":{\"level1\":{\"level2\":{\"n\":25}}}}", syntheticSource);
}

protected void validateRoundTripReader(String syntheticSource, DirectoryReader reader, DirectoryReader roundTripReader)
throws IOException {
// We exclude ignored source field since in some cases it contains an exact copy of a part of document source.
Expand Down

0 comments on commit 3854eb2

Please sign in to comment.