vigyasharma commented on code in PR #13285:
URL: https://github.com/apache/lucene/pull/13285#discussion_r1691961312


##########
lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java:
##########
@@ -143,27 +156,23 @@ protected boolean match(int doc) {
           }
 
           // Perform an approximate search
-          TopDocs results = approximateSearch(context, acceptDocs, 
cardinality);
+          TopDocs results =
+              approximateSearch(context, acceptDocs, cardinality, 
timeLimitingKnnCollectorManager);
 
-          // If the limit was exhausted
-          if (results.totalHits.relation == 
TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO) {
-            // Return a lazy-loading iterator
-            vectorSimilarityScorer =
-                VectorSimilarityScorer.fromAcceptDocs(
-                    this,
-                    boost,
-                    createVectorScorer(context),
-                    new BitSetIterator(acceptDocs, cardinality),
-                    resultSimilarity);
-          } else if (results.scoreDocs.length == 0) {
-            return null;
-          } else {
+          if (results.totalHits.relation == TotalHits.Relation.EQUAL_TO
+              // Return partial results only when timeout is met
+              || (queryTimeout != null && queryTimeout.shouldExit())) {
             // Return an iterator over the collected results
-            vectorSimilarityScorer =
-                VectorSimilarityScorer.fromScoreDocs(this, boost, 
results.scoreDocs);
+            return VectorSimilarityScorerSupplier.fromScoreDocs(boost, 
results.scoreDocs);
+          } else {

Review Comment:
   Do we also have a test for this case, where we exhaust the filter before 
hitting timeout? I guess 
[testFilterWithNoMatches()](https://github.com/apache/lucene/blob/main/lucene/core/src/test/org/apache/lucene/search/BaseVectorSimilarityQueryTestCase.java#L193)
 tests it but only for `null` QueryTimeout values? Do we need one for non-null 
timeouts as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to