msokolov commented on code in PR #11781:
URL: https://github.com/apache/lucene/pull/11781#discussion_r973782739


##########
lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java:
##########
@@ -555,6 +556,78 @@ public void testDiversity() throws IOException {
     assertLevel0Neighbors(builder.hnsw, 5, 1, 4);
   }
 
+  public void testDiversityFallback() throws IOException {
+    vectorEncoding = randomVectorEncoding();
+    similarityFunction = VectorSimilarityFunction.EUCLIDEAN;
+    // Some test cases can't be exercised in two dimensions;
+    // in particular if a new neighbor displaces an existing neighbor
+    // by being closer to the target, yet none of the existing neighbors is 
closer to the new vector
+    // than to the target -- ie they all remain diverse, so we simply drop the 
farthest one.
+    float[][] values = {
+      {0, 0, 0},
+      {0, 1, 0},
+      {0, 0, 2},
+      {1, 0, 0},
+      {0, 0.4f, 0}

Review Comment:
   hm, I guess this works for bytes too, but we should probably multiply 
everything here to make it non-fractional



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