Skip to content

Commit 570b2e4

Browse files
committed
... annnnd... fix more tests
1 parent 4a70860 commit 570b2e4

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public void testInvalidInferenceEndpoints() {
384384
}
385385
}
386386

387-
private SemanticTextIndexOptions getDefaultIndexOptionsForMapper(MapperService mapperService) {
387+
private SemanticTextIndexOptions getDefaultSparseVectorIndexOptionsForMapper(MapperService mapperService) {
388388
var mapperIndexVersion = mapperService.getIndexSettings().getIndexVersionCreated();
389389
var defaultSparseVectorIndexOptions = SparseVectorFieldMapper.SparseVectorIndexOptions.getDefaultIndexOptions(mapperIndexVersion);
390390
return defaultSparseVectorIndexOptions == null
@@ -453,7 +453,7 @@ public void testMultiFieldsSupport() throws IOException {
453453
b.endObject();
454454
b.endObject();
455455
}), useLegacyFormat);
456-
var expectedIndexOptions = getDefaultIndexOptionsForMapper(mapperService);
456+
var expectedIndexOptions = getDefaultSparseVectorIndexOptionsForMapper(mapperService);
457457
assertSemanticTextField(mapperService, "field", true, null, expectedIndexOptions);
458458

459459
mapperService = createMapperService(fieldMapping(b -> {
@@ -472,8 +472,9 @@ public void testMultiFieldsSupport() throws IOException {
472472
b.endObject();
473473
b.endObject();
474474
}), useLegacyFormat);
475-
assertSemanticTextField(mapperService, "field", true, null, null);
476-
assertSemanticTextField(mapperService, "field.semantic", true, null, null);
475+
expectedIndexOptions = getDefaultSparseVectorIndexOptionsForMapper(mapperService);
476+
assertSemanticTextField(mapperService, "field", true, null, expectedIndexOptions);
477+
assertSemanticTextField(mapperService, "field.semantic", true, null, expectedIndexOptions);
477478

478479
Exception e = expectThrows(MapperParsingException.class, () -> createMapperService(fieldMapping(b -> {
479480
b.field("type", "semantic_text");
@@ -571,14 +572,16 @@ public void testUpdateModelSettings() throws IOException {
571572
.endObject()
572573
)
573574
);
574-
assertSemanticTextField(mapperService, fieldName, true, null, null);
575+
var expectedIndexOptions = getDefaultSparseVectorIndexOptionsForMapper(mapperService);
576+
assertSemanticTextField(mapperService, fieldName, true, null, expectedIndexOptions);
575577
}
576578
{
577579
merge(
578580
mapperService,
579581
mapping(b -> b.startObject(fieldName).field("type", "semantic_text").field("inference_id", "test_model").endObject())
580582
);
581-
assertSemanticTextField(mapperService, fieldName, true, null, null);
583+
var expectedIndexOptions = getDefaultSparseVectorIndexOptionsForMapper(mapperService);
584+
assertSemanticTextField(mapperService, fieldName, true, null, expectedIndexOptions);
582585
}
583586
{
584587
Exception exc = expectThrows(
@@ -790,7 +793,7 @@ public void testUpdateSearchInferenceId() throws IOException {
790793
inferenceId,
791794
new MinimalServiceSettings("my-service", TaskType.SPARSE_EMBEDDING, null, null, null)
792795
);
793-
var expectedIndexOptions = getDefaultIndexOptionsForMapper(mapperService);
796+
var expectedIndexOptions = getDefaultSparseVectorIndexOptionsForMapper(mapperService);
794797
assertSemanticTextField(mapperService, fieldName, true, null, expectedIndexOptions);
795798
assertInferenceEndpoints(mapperService, fieldName, inferenceId, inferenceId);
796799

@@ -807,11 +810,7 @@ public void testUpdateSearchInferenceId() throws IOException {
807810
assertInferenceEndpoints(mapperService, fieldName, inferenceId, inferenceId);
808811
}
809812
}
810-
811-
private static void assertSemanticTextField(MapperService mapperService, String fieldName, boolean expectedModelSettings) {
812-
assertSemanticTextField(mapperService, fieldName, expectedModelSettings, null, null);
813-
}
814-
813+
815814
private static void assertSemanticTextField(
816815
MapperService mapperService,
817816
String fieldName,

0 commit comments

Comments
 (0)