@@ -262,7 +262,7 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
262262 return delegateFieldValueFetcher (searchExecutionContext , textFieldType .syntheticSourceDelegate ().get ());
263263 } else {
264264 // otherwise, fetch the value from self
265- return storedFieldFetcher (syntheticSourceFallbackFieldName (true ));
265+ return storedFieldFetcher (name (), syntheticSourceFallbackFieldName (true ));
266266 }
267267 }
268268
@@ -329,17 +329,20 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
329329 final SearchExecutionContext searchExecutionContext ,
330330 final KeywordFieldMapper .KeywordFieldType keywordDelegate
331331 ) {
332- // since we don't know whether the field will be ignored during parsing (ex. when value trips ignore_above)
333- // we must look for both, the expected field name (if parsing of the field was successful), and the backup
334- // field name (if the field was ignored during parsing)
335- final String expectedFieldName = keywordDelegate .name ();
336- final String backupFieldName = keywordDelegate .syntheticSourceFallbackFieldName (true );
332+ // because we don't know whether the delegate field will be ignored during parsing, we must also check the current field
333+ String fieldName = name ();
334+ String fallbackName = syntheticSourceFallbackFieldName (true );
335+
336+ // delegate field names
337+ String delegateFieldName = keywordDelegate .name ();
338+ String delegateFieldFallbackName = keywordDelegate .syntheticSourceFallbackFieldName (true );
337339
338340 if (keywordDelegate .isStored ()) {
339- return storedFieldFetcher (expectedFieldName , backupFieldName );
341+ return storedFieldFetcher (delegateFieldName , delegateFieldFallbackName , fieldName , fallbackName );
340342 } else if (keywordDelegate .hasDocValues ()) {
341343 var ifd = searchExecutionContext .getForField (keywordDelegate , MappedFieldType .FielddataOperation .SEARCH );
342- return combineFieldFetchers (docValuesFieldFetcher (ifd ), storedFieldFetcher (backupFieldName ));
344+ return combineFieldFetchers (docValuesFieldFetcher (ifd ),
345+ storedFieldFetcher (delegateFieldFallbackName , fieldName , fallbackName ));
343346 } else {
344347 assert false : "multi field should either be stored or have doc values" ;
345348 return sourceFieldValueFetcher (searchExecutionContext );
0 commit comments