Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/112706.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 112706
summary: Configure keeping source in `FieldMapper`
area: Mapping
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ private Optional<MatchResult> matchWithFieldSpecificMatcher(String fieldName, Li

// Checks for scenarios when source is stored exactly and therefore can be compared without special logic.
private boolean sourceMatchesExactly(MappingTransforms.FieldMapping mapping, List<Object> expectedValues) {
return mapping.parentMappingParameters().stream().anyMatch(m -> m.getOrDefault("enabled", "true").equals("false"));
return mapping.parentMappingParameters().stream().anyMatch(m -> m.getOrDefault("enabled", "true").equals("false"))
|| mapping.mappingParameters().getOrDefault("synthetic_source_keep", "none").equals("all")
|| expectedValues.size() > 1 && mapping.mappingParameters().getOrDefault("synthetic_source_keep", "none").equals("arrays");
}

private MatchResult matchWithGenericMatcher(List<Object> actualValues, List<Object> expectedValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public MatchOnlyTextFieldType fieldType() {

@Override
protected SyntheticSourceSupport syntheticSourceSupport() {
var loader = new StringStoredFieldFieldLoader(fieldType().storedFieldNameForSyntheticSource(), leafName()) {
var loader = new StringStoredFieldFieldLoader(fieldType().storedFieldNameForSyntheticSource(), fieldType().name(), leafName()) {
@Override
protected void write(XContentBuilder b, Object value) throws IOException {
b.value((String) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ protected void write(XContentBuilder b, Object value) throws IOException {

var kwd = TextFieldMapper.SyntheticSourceHelper.getKeywordFieldMapperForSyntheticSource(this);
if (kwd != null) {
return new SyntheticSourceSupport.Native(kwd.syntheticFieldLoader(leafName()));
return new SyntheticSourceSupport.Native(kwd.syntheticFieldLoader(fullPath(), leafName()));
}

return super.syntheticSourceSupport();
Expand Down
Loading