Skip to content

Commit b8f0584

Browse files
committed
Added more bwc checks
1 parent 6aa57a9 commit b8f0584

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
684684
// match_only_text isn't stored, so if synthetic source needs to be supported, we must do something about it
685685
if (needsToSupportSyntheticSource()) {
686686
// check if we can use the delegate
687-
if (fieldType().textFieldType.canUseSyntheticSourceDelegateForSyntheticSource(value.string())) {
687+
if (fieldType().textFieldType.canUseSyntheticSourceDelegateForSyntheticSource(value.string(), indexCreatedVersion)) {
688688
return;
689689
}
690690

plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
584584
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something else
585585
if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
586586
// if we can rely on the synthetic source delegate for synthetic source, then return
587-
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value)) {
587+
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value, indexCreatedVersion)) {
588588
return;
589589
}
590590

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,10 @@ private boolean indexValue(DocumentParserContext context, String value) {
12261226
*/
12271227
private boolean storeIgnoredValuesForSyntheticSource() {
12281228
// skip all fields that are multi-fields
1229-
return fieldType().isSyntheticSourceEnabled && fieldType().isWithinMultiField == false;
1229+
if (TextFamilyFieldMapper.keywordMultiFieldsNotStoredWhenIgnored_indexVersionCheck(indexCreatedVersion)) {
1230+
return fieldType().isSyntheticSourceEnabled && fieldType().isWithinMultiField == false;
1231+
}
1232+
return fieldType().isSyntheticSourceEnabled;
12301233
}
12311234

12321235
private boolean indexValue(DocumentParserContext context, XContentString value) {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,13 @@ public boolean canUseSyntheticSourceDelegateForQuerying() {
10411041
/**
10421042
* Returns whether this field can use its delegate keyword field for synthetic source.
10431043
*/
1044-
public boolean canUseSyntheticSourceDelegateForSyntheticSource(final String value) {
1044+
public boolean canUseSyntheticSourceDelegateForSyntheticSource(final String value, final IndexVersion indexCreatedVersion) {
10451045
if (syntheticSourceDelegate.isPresent()) {
1046-
// if the keyword field is going to be ignored, then we can't rely on it for synthetic source
1047-
return syntheticSourceDelegate.get().isIgnored(value) == false;
1046+
if (TextFamilyFieldMapper.keywordMultiFieldsNotStoredWhenIgnored_indexVersionCheck(indexCreatedVersion)) {
1047+
// if the keyword field is going to be ignored, then we can't rely on it for synthetic source
1048+
return syntheticSourceDelegate.get().isIgnored(value) == false;
1049+
}
1050+
return true;
10481051
}
10491052
return false;
10501053
}
@@ -1418,7 +1421,7 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
14181421
// if synthetic source needs to be supported, yet the field isn't stored, then we need to rely on something else
14191422
if (needsToSupportSyntheticSource() && fieldType.stored() == false) {
14201423
// if we can rely on the synthetic source delegate for synthetic source, then exit as there is nothing to do
1421-
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value)) {
1424+
if (fieldType().canUseSyntheticSourceDelegateForSyntheticSource(value, indexCreatedVersion)) {
14221425
return;
14231426
}
14241427

0 commit comments

Comments
 (0)