jtibshirani commented on a change in pull request #239:
URL: https://github.com/apache/lucene/pull/239#discussion_r685344896



##########
File path: 
lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestLucene90HnswVectorsFormat.java
##########
@@ -16,13 +16,79 @@
  */
 package org.apache.lucene.codecs.lucene90;
 
+import static com.carrotsearch.randomizedtesting.RandomizedTest.frequently;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.KnnVectorField;
+import org.apache.lucene.document.StringField;
 import org.apache.lucene.index.BaseKnnVectorsFormatTestCase;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.TestUtil;
 
 public class TestLucene90HnswVectorsFormat extends 
BaseKnnVectorsFormatTestCase {
   @Override
   protected Codec getCodec() {
     return TestUtil.getDefaultCodec();
   }
+
+  public void testSearchWithDeletions() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriterConfig cfg = new IndexWriterConfig();
+    IndexWriter w = new IndexWriter(dir, cfg);
+
+    final int numDocs = atLeast(100);
+    final int dim = 30;
+    int docIndex = 0;
+    for (int i = 0; i < numDocs; ++i) {
+      Document d = new Document();
+      if (frequently()) {
+        d.add(new StringField("id", String.valueOf(docIndex), 
Field.Store.YES));
+        d.add(new KnnVectorField("vector", randomVector(dim)));
+        docIndex++;
+      } else {
+        d.add(new StringField("other", "value", Field.Store.NO));

Review comment:
       This is a good idea, it actually helped catch a test bug.




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