Skip to content

Commit 9df4ba5

Browse files
committed
Clean up semantic text field mapper tests (elastic#127853)
(cherry picked from commit 9e542c0) # Conflicts: # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
1 parent 9633d6c commit 9df4ba5

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
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/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) {
@@ -1187,8 +1179,7 @@ public void testDefaultIndexOptions() throws IOException {
11871179
}),
11881180
useLegacyFormat,
11891181
IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT,
1190-
IndexVersionUtils.getPreviousVersion(IndexVersions.SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X),
1191-
true
1182+
IndexVersionUtils.getPreviousVersion(IndexVersions.SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X)
11921183
);
11931184
assertSemanticTextField(mapperService, "field", true, null, defaultDenseVectorIndexOptions());
11941185

0 commit comments

Comments
 (0)