kaivalnp commented on code in PR #15836:
URL: https://github.com/apache/lucene/pull/15836#discussion_r2957225112


##########
lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java:
##########
@@ -122,7 +122,17 @@ public ScorerSupplier scorerSupplier(LeafReaderContext 
context) throws IOExcepti
 
         // If there is no filter
         if (filterWeight == null) {
-          // Return exhaustive results
+          if (traversalSimilarity == Float.NEGATIVE_INFINITY && queryTimeout 
== null) {
+            // When traversalSimilarity is -∞ and there is no timeout, the 
intent is to
+            // find all vectors above resultSimilarity. The approximate graph 
search may
+            // miss nodes in this case, so use exact search to guarantee 
completeness.
+            return VectorSimilarityScorerSupplier.fromAcceptDocs(
+                boost,
+                createVectorScorer(context),
+                DocIdSetIterator.all(leafReader.maxDoc()),

Review Comment:
   Would this also match "not live" docs?
   
   Can we pull the `AcceptDocs.fromLiveDocs` above, and use its iterator here?



##########
lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java:
##########


Review Comment:
   Should we avoid approximate search in the filtered case too?



##########
lucene/CHANGES.txt:
##########
@@ -156,6 +157,9 @@ Bug Fixes
 * GITHUB#14971: Fix CachedExecutor thread pool leak in ConcurrentMergeScheduler
   when IndexWriter initialization fails. (Su Beom)
 
+* GITHUB#15836: Use exact search in VectorSimilarityQuery when 
traversalSimilarity is infinity to

Review Comment:
   `infinity` -> `-infinity`?



##########
lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java:
##########
@@ -122,7 +122,17 @@ public ScorerSupplier scorerSupplier(LeafReaderContext 
context) throws IOExcepti
 
         // If there is no filter
         if (filterWeight == null) {
-          // Return exhaustive results
+          if (traversalSimilarity == Float.NEGATIVE_INFINITY && queryTimeout 
== null) {

Review Comment:
   Do we need the `queryTimeout == null` check here?
   
   For e.g. if a user sets a high value as a performance guardrail, but still 
wants exact search to be performed?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to