Skip to content

Commit d1078aa

Browse files
committed
Fixed failing tests
1 parent 3503532 commit d1078aa

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

server/src/main/java/org/elasticsearch/index/IndexVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ private static Version parseUnchecked(String version) {
186186
public static final IndexVersion TSID_CREATED_DURING_ROUTING = def(9_037_0_00, Version.LUCENE_10_2_2);
187187
public static final IndexVersion UPGRADE_TO_LUCENE_10_3_0 = def(9_038_0_00, Version.LUCENE_10_3_0);
188188
public static final IndexVersion IGNORED_SOURCE_COALESCED_ENTRIES = def(9_039_0_00, Version.LUCENE_10_3_0);
189+
public static final IndexVersion KEYWORD_MULTI_FIELDS_NOT_STORED_WHEN_IGNORED = def(9_040_0_00, Version.LUCENE_10_3_0);
189190

190191
/*
191192
* STOP! READ THIS FIRST! No, really,

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)