Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.query.SearchExecutionContext;

Expand All @@ -35,7 +36,12 @@ public abstract class InferenceMetadataFieldsMapper extends MetadataFieldMapper
*/
public static final Setting<Boolean> USE_LEGACY_SEMANTIC_TEXT_FORMAT = Setting.boolSetting(
"index.mapping.semantic_text.use_legacy_format",
false,
s -> {
// Check index version SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP because that index version was added in the same serverless promotion
// where the new format was enabled by default
IndexVersion indexVersion = IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(s);
return Boolean.toString(indexVersion.before(IndexVersions.SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP));
},
Setting.Property.Final,
Setting.Property.IndexScope,
Setting.Property.InternalIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ public void testIsEnabled() {
assertTrue(InferenceMetadataFieldsMapper.isEnabled(settings));
}

public void testIsEnabledByDefault() {
// Check index version SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP because that index version was added in the same serverless promotion
// where the new format was enabled by default
var settings = Settings.builder()
.put(
IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(),
IndexVersionUtils.getPreviousVersion(IndexVersions.SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP)
)
.build();
assertFalse(InferenceMetadataFieldsMapper.isEnabled(settings));

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

@Override
public void testFieldHasValue() {
assertTrue(
Expand Down