Skip to content

Commit 4e02782

Browse files
committed
Use function to determine default value for index.mapping.semantic_text.use_legacy_format
1 parent 92d1d31 commit 4e02782

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.cluster.metadata.IndexMetadata;
1616
import org.elasticsearch.common.settings.Setting;
1717
import org.elasticsearch.common.settings.Settings;
18+
import org.elasticsearch.index.IndexVersion;
1819
import org.elasticsearch.index.IndexVersions;
1920
import org.elasticsearch.index.query.SearchExecutionContext;
2021

@@ -35,7 +36,12 @@ public abstract class InferenceMetadataFieldsMapper extends MetadataFieldMapper
3536
*/
3637
public static final Setting<Boolean> USE_LEGACY_SEMANTIC_TEXT_FORMAT = Setting.boolSetting(
3738
"index.mapping.semantic_text.use_legacy_format",
38-
false,
39+
s -> {
40+
// Check index version SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP because that index version was added in the same serverless promotion
41+
// where the new format was enabled by default
42+
IndexVersion indexVersion = IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(s);
43+
return Boolean.toString(indexVersion.before(IndexVersions.SOURCE_MAPPER_MODE_ATTRIBUTE_NOOP));
44+
},
3945
Setting.Property.Final,
4046
Setting.Property.IndexScope,
4147
Setting.Property.InternalIndex

0 commit comments

Comments
 (0)