Skip to content

Commit 3260326

Browse files
committed
... and fix tests...
1 parent 6d9cecc commit 3260326

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextIndexOptions.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, Object> map,
8181
SPARSE_VECTOR("sparse_vector") {
8282
@Override
8383
public IndexOptions parseIndexOptions(String fieldName, Map<String, Object> map, IndexVersion indexVersion) {
84-
SparseVectorFieldMapper.SparseVectorIndexOptions indexOptions = parseSparseVectorIndexOptionsFromMap(map);
85-
return (SparseVectorFieldMapper.SparseVectorIndexOptions.isDefaultOptions(indexOptions, indexVersion))
86-
? null
87-
: indexOptions;
84+
return parseSparseVectorIndexOptionsFromMap(map);
8885
}
8986
};
9087

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,9 @@ private static void assertSemanticTextField(
794794
IndexVersion indexVersion = mapperService.getIndexSettings().getIndexVersionCreated();
795795

796796
SparseVectorFieldMapper.SparseVectorIndexOptions applied = sparseVectorFieldMapper.fieldType().getIndexOptions();
797-
SparseVectorFieldMapper.SparseVectorIndexOptions expected = (expectedIndexOptions != null)
798-
? (SparseVectorFieldMapper.SparseVectorIndexOptions) expectedIndexOptions.indexOptions()
799-
: SparseVectorFieldMapper.SparseVectorIndexOptions.getDefaultIndexOptions(indexVersion);
797+
SparseVectorFieldMapper.SparseVectorIndexOptions expected = expectedIndexOptions == null
798+
? SparseVectorFieldMapper.SparseVectorIndexOptions.getDefaultIndexOptions(indexVersion)
799+
: (SparseVectorFieldMapper.SparseVectorIndexOptions)expectedIndexOptions.indexOptions();
800800
assertEquals(expected, applied);
801801
}
802802
case TEXT_EMBEDDING -> {
@@ -1403,17 +1403,6 @@ public void testDefaultIndexOptions() throws IOException {
14031403
);
14041404
assertSemanticTextField(mapperService, "field", true, null, defaultDenseVectorSemanticIndexOptions());
14051405

1406-
IndexVersion sparseVectorIndexVersion = randomBoolean()
1407-
? IndexVersionUtils.randomVersionBetween(
1408-
random(),
1409-
IndexVersions.UPGRADE_TO_LUCENE_10_0_0,
1410-
IndexVersionUtils.getPreviousVersion(IndexVersions.SPARSE_VECTOR_PRUNING_INDEX_OPTIONS_SUPPORT)
1411-
)
1412-
: IndexVersionUtils.randomVersionBetween(
1413-
random(),
1414-
IndexVersions.SPARSE_VECTOR_PRUNING_INDEX_OPTIONS_SUPPORT,
1415-
IndexVersion.current()
1416-
);
14171406
mapperService = createMapperService(fieldMapping(b -> {
14181407
b.field("type", "semantic_text");
14191408
b.field("inference_id", "another_inference_id");
@@ -1425,7 +1414,14 @@ public void testDefaultIndexOptions() throws IOException {
14251414
IndexVersionUtils.getPreviousVersion(IndexVersions.SPARSE_VECTOR_PRUNING_INDEX_OPTIONS_SUPPORT),
14261415
IndexVersions.SPARSE_VECTOR_PRUNING_INDEX_OPTIONS_SUPPORT
14271416
);
1428-
assertSemanticTextField(mapperService, "field", true, null, defaultSparseVectorIndexOptions(sparseVectorIndexVersion));
1417+
1418+
assertSemanticTextField(
1419+
mapperService,
1420+
"field",
1421+
true,
1422+
null,
1423+
defaultSparseVectorIndexOptions(mapperService.getIndexSettings().getIndexVersionCreated())
1424+
);
14291425
}
14301426

14311427
public void testSpecifiedDenseVectorIndexOptions() throws IOException {

0 commit comments

Comments
 (0)