Skip to content

Commit dbdbc6d

Browse files
committed
test fixes
1 parent 19df568 commit dbdbc6d

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/80_dense_vector_indexed_by_default.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ setup:
9090
type: dense_vector
9191
dims: 5
9292
index: false
93-
early_termination: false
9493
---
9594
"Not indexed vector - vector similarity":
9695
- do:
@@ -177,4 +176,3 @@ setup:
177176
- match: { test_default_index_options.mappings.properties.vector.index: true }
178177
- match: { test_default_index_options.mappings.properties.vector.similarity: cosine }
179178
- is_false: test_default_index_options.mappings.properties.vector.index_options.type
180-
- match: { test_default_index_options.mappings.properties.vector.index_options.early_termination: false }

server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldTypeTests.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,11 @@ public void testRescoreOversampleQueryOverrides() {
682682
public void testFilterSearchThreshold() {
683683
List<Tuple<DenseVectorFieldMapper.ElementType, Function<Query, KnnSearchStrategy>>> cases = List.of(
684684
Tuple.tuple(FLOAT, q -> q instanceof PatienceKnnVectorQuery patienceKnnVectorQuery ?
685-
patienceKnnVectorQuery.getSearchStrategy() : ((ESKnnFloatVectorQuery) q).getStrategy()),
685+
null : ((ESKnnFloatVectorQuery) q).getStrategy()),
686686
Tuple.tuple(BYTE, q -> q instanceof PatienceKnnVectorQuery patienceKnnVectorQuery ?
687-
patienceKnnVectorQuery.getSearchStrategy() : ((ESKnnByteVectorQuery) q).getStrategy()),
687+
null : ((ESKnnByteVectorQuery) q).getStrategy()),
688688
Tuple.tuple(BIT, q -> q instanceof PatienceKnnVectorQuery patienceKnnVectorQuery ?
689-
patienceKnnVectorQuery.getSearchStrategy() : ((ESKnnByteVectorQuery) q).getStrategy())
689+
null : ((ESKnnByteVectorQuery) q).getStrategy())
690690
);
691691
for (var tuple : cases) {
692692
DenseVectorFieldType fieldType = new DenseVectorFieldType(
@@ -713,22 +713,24 @@ public void testFilterSearchThreshold() {
713713
DenseVectorFieldMapper.FilterHeuristic.FANOUT
714714
);
715715
KnnSearchStrategy strategy = tuple.v2().apply(query);
716-
assertTrue(strategy instanceof KnnSearchStrategy.Hnsw);
717-
assertThat(((KnnSearchStrategy.Hnsw) strategy).filteredSearchThreshold(), equalTo(0));
718-
719-
query = fieldType.createKnnQuery(
720-
VectorData.fromFloats(new float[] { 1, 4, 10 }),
721-
10,
722-
100,
723-
0f,
724-
null,
725-
null,
726-
null,
727-
DenseVectorFieldMapper.FilterHeuristic.ACORN
728-
);
729-
strategy = tuple.v2().apply(query);
730-
assertTrue(strategy instanceof KnnSearchStrategy.Hnsw);
731-
assertThat(((KnnSearchStrategy.Hnsw) strategy).filteredSearchThreshold(), equalTo(60));
716+
if (strategy != null) {
717+
assertTrue(strategy instanceof KnnSearchStrategy.Hnsw);
718+
assertThat(((KnnSearchStrategy.Hnsw) strategy).filteredSearchThreshold(), equalTo(0));
719+
720+
query = fieldType.createKnnQuery(
721+
VectorData.fromFloats(new float[]{1, 4, 10}),
722+
10,
723+
100,
724+
0f,
725+
null,
726+
null,
727+
null,
728+
DenseVectorFieldMapper.FilterHeuristic.ACORN
729+
);
730+
strategy = tuple.v2().apply(query);
731+
assertTrue(strategy instanceof KnnSearchStrategy.Hnsw);
732+
assertThat(((KnnSearchStrategy.Hnsw) strategy).filteredSearchThreshold(), equalTo(60));
733+
}
732734
}
733735
}
734736

0 commit comments

Comments
 (0)