Skip to content

Commit 810e77a

Browse files
committed
Removed isIndexed check, swap order of field loader layers
1 parent cb0a2ab commit 810e77a

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
688688
final var bytesRef = new BytesRef(utfBytes.bytes(), utfBytes.offset(), utfBytes.length());
689689
context.doc().add(new StoredField(fieldName, bytesRef));
690690
} else {
691-
692691
context.doc().add(new StoredField(fieldName, value.string()));
693692
}
694693
}
@@ -735,7 +734,7 @@ protected void writeValue(Object value, XContentBuilder b) throws IOException {
735734
var kwd = TextFieldMapper.SyntheticSourceHelper.getKeywordFieldMapperForSyntheticSource(this);
736735
if (kwd != null) {
737736
// merge the two field loaders into one
738-
return fieldLoader.mergedWith(kwd.syntheticFieldLoader(fullPath(), leafName()));
737+
return kwd.syntheticFieldLoader(fullPath(), leafName()).mergedWith(fieldLoader);
739738
}
740739

741740
return fieldLoader;

plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,10 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
563563
if (fieldType.omitNorms()) {
564564
context.addToFieldNames(fieldType().name());
565565
}
566-
} else if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
567-
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something
568-
// else to support synthetic source
566+
}
569567

568+
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something else
569+
if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
570570
// if we can rely on the synthetic source delegate for synthetic source, then return
571571
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value)) {
572572
return;
@@ -621,7 +621,7 @@ protected void writeValue(Object value, XContentBuilder b) throws IOException {
621621
var kwd = TextFieldMapper.SyntheticSourceHelper.getKeywordFieldMapperForSyntheticSource(this);
622622
if (kwd != null) {
623623
// merge the two field loaders into one
624-
return fieldLoader.mergedWith(kwd.syntheticFieldLoader(fullPath(), leafName()));
624+
return kwd.syntheticFieldLoader(fullPath(), leafName()).mergedWith(fieldLoader);
625625
}
626626

627627
return fieldLoader;

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,9 +1450,10 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
14501450
if (phraseFieldInfo != null) {
14511451
context.doc().add(new Field(phraseFieldInfo.field, value, phraseFieldInfo.fieldType));
14521452
}
1453-
} else if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
1454-
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something else
1453+
}
14551454

1455+
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something else
1456+
if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
14561457
// if we can rely on the synthetic source delegate for synthetic source, then exit as there is nothing to do
14571458
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value)) {
14581459
return;
@@ -1638,10 +1639,6 @@ protected void write(XContentBuilder b, Object value) throws IOException {
16381639
});
16391640
}
16401641

1641-
if (isIndexed()) {
1642-
return super.syntheticSourceSupport();
1643-
}
1644-
16451642
return new SyntheticSourceSupport.Native(() -> syntheticFieldLoader(fullPath(), leafName()));
16461643
}
16471644

@@ -1664,7 +1661,7 @@ protected void writeValue(Object value, XContentBuilder b) throws IOException {
16641661
var kwd = TextFieldMapper.SyntheticSourceHelper.getKeywordFieldMapperForSyntheticSource(this);
16651662
if (kwd != null) {
16661663
// merge the two field loaders into one
1667-
return fieldLoader.mergedWith(kwd.syntheticFieldLoader(fullPath(), leafName()));
1664+
return kwd.syntheticFieldLoader(fullPath(), leafName()).mergedWith(fieldLoader);
16681665
}
16691666

16701667
return fieldLoader;

0 commit comments

Comments
 (0)