Skip to content

Commit

Permalink
Merge branch '8.18' into backport/8.18/pr-121706
Browse files Browse the repository at this point in the history
  • Loading branch information
jdconrad authored Feb 5, 2025
2 parents d8d5373 + 09a7665 commit 27300ad
Show file tree
Hide file tree
Showing 4 changed files with 40 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: []
6 changes: 6 additions & 0 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,9 @@ tests:
- class: org.elasticsearch.xpack.migrate.action.ReindexDatastreamIndexTransportActionIT
method: testFailIfMetadataBlockSet
issue: https://github.com/elastic/elasticsearch/issues/121774
- class: org.elasticsearch.xpack.ml.packageloader.action.ModelLoaderUtilsTests
method: testSplitIntoRanges
issue: https://github.com/elastic/elasticsearch/issues/121799
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
method: testLookupExplosionBigStringManyMatches
issue: https://github.com/elastic/elasticsearch/issues/121465
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 27300ad

Please sign in to comment.