Don't generate mappings that copy_to into itself (#119997)

This commit is contained in:
Oleksandr Kolomiiets 2025-01-22 11:27:14 -08:00 committed by GitHub
parent a620e7c976
commit e7a9690186
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -101,11 +101,6 @@ public class MappingGenerator {
}
if (templateEntry instanceof Template.Leaf leaf) {
// For simplicity we only copy to keyword fields, synthetic source logic to handle copy_to is generic.
if (leaf.type() == FieldType.KEYWORD) {
context.addCopyToCandidate(fieldName);
}
var mappingParametersGenerator = specification.dataSource()
.get(
new DataSourceRequest.LeafMappingParametersGenerator(
@ -120,6 +115,11 @@ public class MappingGenerator {
mappingParameters.put("type", leaf.type().toString());
mappingParameters.putAll(mappingParametersGenerator.get());
// For simplicity we only copy to keyword fields, synthetic source logic to handle copy_to is generic.
if (leaf.type() == FieldType.KEYWORD) {
context.addCopyToCandidate(fieldName);
}
} else if (templateEntry instanceof Template.Object object) {
var mappingParametersGenerator = specification.dataSource()
.get(new DataSourceRequest.ObjectMappingParametersGenerator(false, object.nested(), context.parentSubobjects()))