mayya-sharipova commented on code in PR #14366:
URL: https://github.com/apache/lucene/pull/14366#discussion_r2005709557


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphSearcher.java:
##########
@@ -266,11 +266,21 @@ void searchLevel(
     // A bound that holds the minimum similarity to the query vector that a 
candidate vector must
     // have to be considered.
     float minAcceptedSimilarity = 
Math.nextUp(results.minCompetitiveSimilarity());
+    // We should allow exploring equivalent minAcceptedSimilarity values at 
least once
+    boolean shouldExploreMinSim = true;
     while (candidates.size() > 0 && results.earlyTerminated() == false) {
       // get the best candidate (closest or best scoring)
       float topCandidateSimilarity = candidates.topScore();
       if (topCandidateSimilarity < minAcceptedSimilarity) {
-        break;
+        // if the similarity is equivalent to the minAcceptedSimilarity, we 
should explore one
+        // candidate
+        // however, running into many duplicates can be expensive, so we 
should stop exploring if
+        // equivalent minimum scores are found
+        if (shouldExploreMinSim && Math.nextUp(candidates.topScore()) == 
minAcceptedSimilarity) {

Review Comment:
   if (shouldExploreMinSim && Math.nextUp(candidates.topScore()) == 
minAcceptedSimilarity) => 
   if (shouldExploreMinSim && Math.nextUp(topCandidateSimilarity) == 
minAcceptedSimilarity)



-- 
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