@@ -249,24 +249,24 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
249
249
if (searchExecutionContext .isSourceSynthetic ()) {
250
250
if (isWithinMultiField ) {
251
251
// fetch the value from parent
252
- return parentFieldValueFetcher (searchExecutionContext );
252
+ return parentFieldFetcher (searchExecutionContext );
253
253
} else if (textFieldType .syntheticSourceDelegate ().isPresent ()) {
254
254
// otherwise, if there is a delegate field, fetch the value from it
255
- return delegateFieldValueFetcher (searchExecutionContext , textFieldType .syntheticSourceDelegate ().get ());
255
+ return delegateFieldFetcher (searchExecutionContext , textFieldType .syntheticSourceDelegate ().get ());
256
256
} else {
257
257
// otherwise, fetch the value from self
258
258
return storedFieldFetcher (name (), syntheticSourceFallbackFieldName ());
259
259
}
260
260
}
261
261
262
262
// otherwise, synthetic source must be disabled, so fetch the value directly from _source
263
- return sourceFieldValueFetcher (searchExecutionContext );
263
+ return sourceFieldFetcher (searchExecutionContext );
264
264
}
265
265
266
266
/**
267
267
* Returns a function that will fetch values directly from _source.
268
268
*/
269
- private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> sourceFieldValueFetcher (
269
+ private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> sourceFieldFetcher (
270
270
final SearchExecutionContext searchExecutionContext
271
271
) {
272
272
return context -> {
@@ -284,9 +284,9 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
284
284
}
285
285
286
286
/**
287
- * Returns a function that will fetch value from a parent field.
287
+ * Returns a function that will fetch fields from the parent field.
288
288
*/
289
- private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> parentFieldValueFetcher (
289
+ private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> parentFieldFetcher (
290
290
final SearchExecutionContext searchExecutionContext
291
291
) {
292
292
assert searchExecutionContext .isSourceSynthetic () : "Synthetic source should be enabled" ;
@@ -311,14 +311,14 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
311
311
return docValuesFieldFetcher (ifd );
312
312
} else {
313
313
assert false : "parent field should either be stored or have doc values" ;
314
- return sourceFieldValueFetcher (searchExecutionContext );
314
+ return sourceFieldFetcher (searchExecutionContext );
315
315
}
316
316
}
317
317
318
318
/**
319
- * Returns a function that will fetch values from a synthetic source delegate .
319
+ * Returns a function that will fetch the fields from the delegate field (ex. keyword multi field) .
320
320
*/
321
- private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> delegateFieldValueFetcher (
321
+ private IOFunction <LeafReaderContext , CheckedIntFunction <List <Object >, IOException >> delegateFieldFetcher (
322
322
final SearchExecutionContext searchExecutionContext ,
323
323
final KeywordFieldMapper .KeywordFieldType keywordDelegate
324
324
) {
@@ -340,7 +340,7 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
340
340
);
341
341
} else {
342
342
assert false : "multi field should either be stored or have doc values" ;
343
- return sourceFieldValueFetcher (searchExecutionContext );
343
+ return sourceFieldFetcher (searchExecutionContext );
344
344
}
345
345
}
346
346
@@ -715,11 +715,11 @@ protected SyntheticSourceSupport syntheticSourceSupport() {
715
715
}
716
716
717
717
private SourceLoader .SyntheticFieldLoader syntheticFieldLoader (String fullFieldName , String leafFieldName ) {
718
- // match_only_text is not stored for space efficiency, except when synthetic source is enabled as synthetic source
719
- // needs something to load to reconstruct source. In such cases, we * might* store this field or we *might* rely
720
- // on a delegate field if one exists . Because of this uncertainty, we need multiple field loaders.
718
+ // we're using two field loaders here because we don't know who was responsible for storing this field to support synthetic source
719
+ // on one hand, if a delegate keyword field exists, then it might've stored the field. However, this is not true if said field was
720
+ // ignored during indexing (ex. it tripped ignore_above) . Because of this uncertainty, we need multiple field loaders.
721
721
722
- // first field loader, representing this field
722
+ // first field loader - to check whether the field's value was stored under this match_only_text field
723
723
final String fieldName = fieldType ().syntheticSourceFallbackFieldName ();
724
724
final var thisFieldLayer = new CompositeSyntheticFieldLoader .StoredFieldLayer (fieldName ) {
725
725
@ Override
@@ -735,7 +735,7 @@ protected void writeValue(Object value, XContentBuilder b) throws IOException {
735
735
736
736
final CompositeSyntheticFieldLoader fieldLoader = new CompositeSyntheticFieldLoader (leafFieldName , fullFieldName , thisFieldLayer );
737
737
738
- // second loader, representing a delegate field, if one exists
738
+ // second loader - to check whether the field's value was stored by a keyword delegate field
739
739
var kwd = TextFieldMapper .SyntheticSourceHelper .getKeywordFieldMapperForSyntheticSource (this );
740
740
if (kwd != null ) {
741
741
// merge the two field loaders into one
0 commit comments