Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/125446.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 125446
summary: Fix Semantic Text 8.x Upgrade Bug
area: Mapping
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public static boolean isEnabled(Settings settings) {
var version = IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(settings);
if ((version.before(IndexVersions.INFERENCE_METADATA_FIELDS)
&& version.between(IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT, IndexVersions.UPGRADE_TO_LUCENE_10_0_0) == false)
|| (version.before(USE_NEW_SEMANTIC_TEXT_FORMAT_BY_DEFAULT) && USE_LEGACY_SEMANTIC_TEXT_FORMAT.exists(settings) == false)) {
|| (version.onOrAfter(IndexVersions.UPGRADE_TO_LUCENE_10_0_0)
&& version.before(USE_NEW_SEMANTIC_TEXT_FORMAT_BY_DEFAULT)
&& USE_LEGACY_SEMANTIC_TEXT_FORMAT.exists(settings) == false)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ public void testIsEnabledByDefault() {
)
.build();
assertTrue(InferenceMetadataFieldsMapper.isEnabled(settings));

// Test upgrades from 8.x
settings = Settings.builder()
.put(
IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(),
IndexVersionUtils.getPreviousVersion(IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT)
)
.build();
assertFalse(InferenceMetadataFieldsMapper.isEnabled(settings));

settings = Settings.builder()
.put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT)
.build();
assertTrue(InferenceMetadataFieldsMapper.isEnabled(settings));
}

@Override
Expand Down
Loading