Skip to content

Commit 868cbff

Browse files
committed
Always propagate index version
1 parent 76ee76a commit 868cbff

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ protected final MapperService createMapperService(Settings settings, String mapp
210210
protected final MapperService createMapperService(IndexVersion indexVersion, Settings settings, XContentBuilder mappings)
211211
throws IOException {
212212
MapperService mapperService = createMapperService(indexVersion, settings, () -> true, mappings);
213-
merge(mapperService, mappings);
214213
return mapperService;
215214
}
216215

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ static IndexVersion getRandomCompatibleIndexVersion(boolean useLegacyFormat, Ind
125125
if (randomBoolean()) {
126126
return IndexVersionUtils.randomVersionBetween(random(), IndexVersions.UPGRADE_TO_LUCENE_10_0_0, maxVersion);
127127
}
128-
return IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT);
128+
return IndexVersionUtils.randomVersionBetween(
129+
random(),
130+
IndexVersions.SEMANTIC_TEXT_FIELD_TYPE,
131+
IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT
132+
);
129133
} else {
130134
if (randomBoolean()) {
131135
return IndexVersionUtils.randomVersionBetween(random(), IndexVersions.INFERENCE_METADATA_FIELDS, maxVersion);

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,35 +153,27 @@ protected Supplier<ModelRegistry> getModelRegistry() {
153153

154154
private MapperService createMapperService(XContentBuilder mappings, boolean useLegacyFormat) throws IOException {
155155
IndexVersion indexVersion = SemanticInferenceMetadataFieldsMapperTests.getRandomCompatibleIndexVersion(useLegacyFormat);
156-
return createMapperService(mappings, useLegacyFormat, indexVersion, indexVersion, false);
156+
return createMapperService(mappings, useLegacyFormat, indexVersion, indexVersion);
157157
}
158158

159159
private MapperService createMapperService(XContentBuilder mappings, boolean useLegacyFormat, IndexVersion minIndexVersion)
160160
throws IOException {
161-
return createMapperService(mappings, useLegacyFormat, minIndexVersion, IndexVersion.current(), false);
161+
return createMapperService(mappings, useLegacyFormat, minIndexVersion, IndexVersion.current());
162162
}
163163

164164
private MapperService createMapperService(
165165
XContentBuilder mappings,
166166
boolean useLegacyFormat,
167167
IndexVersion minIndexVersion,
168-
IndexVersion maxIndexVersion,
169-
boolean propagateIndexVersion
168+
IndexVersion maxIndexVersion
170169
) throws IOException {
171170
validateIndexVersion(minIndexVersion, useLegacyFormat);
172171
IndexVersion indexVersion = IndexVersionUtils.randomVersionBetween(random(), minIndexVersion, maxIndexVersion);
173172
var settings = Settings.builder()
174173
.put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), indexVersion)
175174
.put(InferenceMetadataFieldsMapper.USE_LEGACY_SEMANTIC_TEXT_FORMAT.getKey(), useLegacyFormat)
176175
.build();
177-
// TODO - This is added, because we discovered a bug where the index version was not being correctly propagated
178-
// in our mappings even though we were specifying the index version in settings. We will fix this in a followup and
179-
// remove the boolean flag accordingly.
180-
if (propagateIndexVersion) {
181-
return createMapperService(indexVersion, settings, mappings);
182-
} else {
183-
return createMapperService(settings, mappings);
184-
}
176+
return createMapperService(indexVersion, settings, mappings);
185177
}
186178

187179
private static void validateIndexVersion(IndexVersion indexVersion, boolean useLegacyFormat) {
@@ -1189,8 +1181,7 @@ public void testDefaultIndexOptions() throws IOException {
11891181
}),
11901182
useLegacyFormat,
11911183
IndexVersions.INFERENCE_METADATA_FIELDS,
1192-
IndexVersionUtils.getPreviousVersion(IndexVersions.SEMANTIC_TEXT_DEFAULTS_TO_BBQ),
1193-
true
1184+
IndexVersionUtils.getPreviousVersion(IndexVersions.SEMANTIC_TEXT_DEFAULTS_TO_BBQ)
11941185
);
11951186
assertSemanticTextField(mapperService, "field", true, null, defaultDenseVectorIndexOptions());
11961187

0 commit comments

Comments
 (0)