@@ -1107,7 +1107,12 @@ protected String delegatingTo() {
11071107                return  new  BlockStoredFieldsReader .BytesFromStringsBlockLoader (name ());
11081108            }
11091109
1110-             // if there is no field to delegate to and this field isn't stored, then fallback to ignored source 
1110+             // _ignored_source field will contain entries for this field if it is not stored 
1111+             // and there is no syntheticSourceDelegate. 
1112+             // See #syntheticSourceSupport(). 
1113+             // But if a text field is a multi field it won't have an entry in _ignored_source. 
1114+             // The parent might, but we don't have enough context here to figure this out. 
1115+             // So we bail. 
11111116            if  (isSyntheticSourceEnabled () && syntheticSourceDelegate .isEmpty () && parentField  == null ) {
11121117                return  fallbackSyntheticSourceBlockLoader (blContext );
11131118            }
@@ -1466,17 +1471,22 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
14661471            }
14671472        }
14681473
1469-         // store the field if isn't stored yet, and we need it to be stored for synthetic source 
1470-         if  (fieldType .stored () == false  && fieldType ().storeFieldForSyntheticSource (indexCreatedVersion )) {
1471-             // if we can rely on the synthetic source delegate for synthetic source, then exit as there is nothing to do 
1474+         // if the field isn't stored, yet we need it stored for synthetic source, then attempt to use the synthetic source delegate 
1475+         if  (fieldType ().storeFieldForSyntheticSource (indexCreatedVersion )
1476+             && fieldType .stored () == false 
1477+             && fieldType ().syntheticSourceDelegate .isPresent ()) {
1478+ 
1479+             // check if the delegate can even handle storing for us 
14721480            if  (fieldType ().canUseSyntheticSourceDelegateForSyntheticSource (value )) {
14731481                return ;
14741482            }
14751483
1476-             // otherwise,  store this  field in Lucene so that synthetic source can load it  
1484+             // if not, then  store the  field ourselves  
14771485            final  String  fieldName  = fieldType ().syntheticSourceFallbackFieldName ();
14781486            context .doc ().add (new  StoredField (fieldName , value ));
14791487        }
1488+ 
1489+         // if we get to this point and synthetic source is enabled, then the field will be stored in ignored source 
14801490    }
14811491
14821492    /** 
@@ -1672,6 +1682,12 @@ protected void write(XContentBuilder b, Object value) throws IOException {
16721682            });
16731683        }
16741684
1685+         // if there is no synthetic source delegate, then fall back to ignored source 
1686+         if  (fieldType ().syntheticSourceDelegate .isEmpty ()) {
1687+             return  super .syntheticSourceSupport ();
1688+         }
1689+ 
1690+         // otherwise, we can use a stored field that was either created by this mapper or the delegate mapper 
16751691        return  new  SyntheticSourceSupport .Native (() -> syntheticFieldLoader (fullPath (), leafName ()));
16761692    }
16771693
0 commit comments