@@ -1221,6 +1221,14 @@ private boolean indexValue(DocumentParserContext context, String value) {
12211221 return indexValue (context , new Text (value ));
12221222 }
12231223
1224+ /**
1225+ * Returns whether this field should be stored separately as a {@link StoredField} for supporting synthetic source.
1226+ */
1227+ private boolean storeIgnoredValuesForSyntheticSource () {
1228+ // skip all fields that are multi-fields
1229+ return fieldType ().isSyntheticSourceEnabled && fieldType ().isWithinMultiField == false ;
1230+ }
1231+
12241232 private boolean indexValue (DocumentParserContext context , XContentString value ) {
12251233 // nothing to index
12261234 if (value == null ) {
@@ -1232,17 +1240,18 @@ private boolean indexValue(DocumentParserContext context, XContentString value)
12321240 return false ;
12331241 }
12341242
1235- // if the value's length exceeds ignore_above, then don't index it. Instead, store it in ignored source
1236- // that being said, don't store multi fields in ignored source as thats the responsibility of the parent
1237- if (value .stringLength () > fieldType ().ignoreAbove () && isWithinMultiField == false ) {
1243+ // if the value's length exceeds ignore_above, then don't index it
1244+ if (value .stringLength () > fieldType ().ignoreAbove ()) {
12381245 context .addIgnoredField (fullPath ());
1239- // unless synthetic source is enabled, then store a copy of the value so that synthetic source be load it
1240- if (fieldType ().isSyntheticSourceEnabled ) {
1246+
1247+ // if synthetic source is enabled, then store a copy of the value so that synthetic source be load it
1248+ if (storeIgnoredValuesForSyntheticSource ()) {
12411249 var utfBytes = value .bytes ();
12421250 var bytesRef = new BytesRef (utfBytes .bytes (), utfBytes .offset (), utfBytes .length ());
12431251 final String fieldName = fieldType ().syntheticSourceFallbackFieldName ();
12441252 context .doc ().add (new StoredField (fieldName , bytesRef ));
12451253 }
1254+
12461255 return false ;
12471256 }
12481257
0 commit comments