Skip to content

Commit c3e5daa

Browse files
committed
Fix KnnSearchBuilderTests#testEqualsAndHashcode failures
The KnnSearchBuilder constructor validates that k is always less than num_cands. But the mutateInstance method could increase k past num_cands. Now we construct the instance with a larger num_cands to make sure this never happens. Closes #88734.
1 parent f284cc1 commit c3e5daa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/src/test/java/org/elasticsearch/search/vectors/KnnSearchBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected KnnSearchBuilder createTestInstance() {
6565
int dim = randomIntBetween(2, 30);
6666
float[] vector = randomVector(dim);
6767
int k = randomIntBetween(1, 100);
68-
int numCands = randomIntBetween(k, 1000);
68+
int numCands = randomIntBetween(k + 20, 1000);
6969

7070
KnnSearchBuilder builder = new KnnSearchBuilder(field, vector, k, numCands);
7171
if (randomBoolean()) {

0 commit comments

Comments
 (0)