Skip to content

Apache Lucene open-source search software

Fix test TestKnnByteVectorQuery.testToString (#13134)

Shubham Chaudhary6eba1fb537f8
diff --git a/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java b/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
index be69f800ba2..525156a2666 100644
--- a/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
@@ -442,7 +442,7 @@ abstract class AbstractKnnVectorQuery extends Query {
@Override
public String toString(String field) {
- return "DocAndScoreQuery[" + docs[0] + ",...][" + scores[0] + ",...]";
+ return "DocAndScoreQuery[" + docs[0] + ",...][" + scores[0] + ",...]," + maxScore;
}
@Override
diff --git a/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java b/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
index 6e3f90fff59..5591a9059c9 100644
--- a/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
+++ b/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
@@ -842,8 +842,8 @@ abstract class BaseKnnVectorQueryTestCase extends LuceneTestCase {
// The string should contain matching docIds and their score.
// Since a forceMerge could occur in this test, we must not assert that a specific doc_id is
// matched
- // But that instead the string format is expected and that the score is 1.0
- assertTrue(queryString.matches("DocAndScoreQuery\\[\\d+,...]\\[1.0,...]"));
+ // But that instead the string format is expected and that the max score is 1.0
+ assertTrue(queryString.matches("DocAndScoreQuery\\[\\d+,...]\\[\\d+.\\d+,...],1.0"));
}
/**