You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/09/29 12:46:37 UTC

[GitHub] [lucene] mayya-sharipova opened a new pull request #326: LUCENE-10126 Add extra test on _doc sort

mayya-sharipova opened a new pull request #326:
URL: https://github.com/apache/lucene/pull/326


   Add extra test on _doc sort to test
   that search with after collects all documents


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] mayya-sharipova commented on pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
mayya-sharipova commented on pull request #326:
URL: https://github.com/apache/lucene/pull/326#issuecomment-930450785


   @dnhatn Thanks for the review.


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] mayya-sharipova commented on pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
mayya-sharipova commented on pull request #326:
URL: https://github.com/apache/lucene/pull/326#issuecomment-930450785


   @dnhatn Thanks for the review.


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] dnhatn commented on a change in pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
dnhatn commented on a change in pull request #326:
URL: https://github.com/apache/lucene/pull/326#discussion_r718495134



##########
File path: lucene/core/src/test/org/apache/lucene/search/TestSortOptimization.java
##########
@@ -483,6 +484,42 @@ public void testDocSortOptimizationWithAfter() throws IOException {
     dir.close();
   }
 
+  public void testDocSortOptimizationWithAfterCollectsAllDocs() throws IOException {
+    final Directory dir = newDirectory();
+    final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig());
+    final int numDocs = atLeast(TEST_NIGHTLY ? 50_000 : 5_000);
+    final boolean multipleSegments = random().nextBoolean();
+    final int numDocsInSegment = numDocs / 10 + random().nextInt(numDocs / 10);
+
+    for (int i = 1; i <= numDocs; ++i) {
+      final Document doc = new Document();
+      writer.addDocument(doc);
+      if (multipleSegments && (i % numDocsInSegment == 0)) {
+        writer.flush();
+      }
+    }
+    writer.flush();
+
+    IndexReader reader = DirectoryReader.open(writer);
+    IndexSearcher searcher = newSearcher(reader);
+    int visitedHits = 0;
+    ScoreDoc after = null;
+    while (visitedHits < numDocs) {
+      int batch = 1 + random().nextInt(500);
+      Query query = new MatchAllDocsQuery();
+      TopDocs topDocs = searcher.searchAfter(after, query, batch, new Sort(FIELD_DOC));
+      int expectedHits = Math.min(numDocs - visitedHits, batch);
+      assertEquals(expectedHits, topDocs.scoreDocs.length);
+      after = topDocs.scoreDocs[expectedHits - 1];
+      for (int i = 0; i < topDocs.scoreDocs.length; i++) {
+        assertEquals(visitedHits, topDocs.scoreDocs[i].doc);
+        visitedHits++;
+      }
+    }
+    assert (visitedHits == numDocs);

Review comment:
       assertEquals instead?




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] mayya-sharipova merged pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
mayya-sharipova merged pull request #326:
URL: https://github.com/apache/lucene/pull/326


   


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] mayya-sharipova merged pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
mayya-sharipova merged pull request #326:
URL: https://github.com/apache/lucene/pull/326


   


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] dnhatn commented on a change in pull request #326: LUCENE-10126 Add extra test on _doc sort

Posted by GitBox <gi...@apache.org>.
dnhatn commented on a change in pull request #326:
URL: https://github.com/apache/lucene/pull/326#discussion_r718495134



##########
File path: lucene/core/src/test/org/apache/lucene/search/TestSortOptimization.java
##########
@@ -483,6 +484,42 @@ public void testDocSortOptimizationWithAfter() throws IOException {
     dir.close();
   }
 
+  public void testDocSortOptimizationWithAfterCollectsAllDocs() throws IOException {
+    final Directory dir = newDirectory();
+    final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig());
+    final int numDocs = atLeast(TEST_NIGHTLY ? 50_000 : 5_000);
+    final boolean multipleSegments = random().nextBoolean();
+    final int numDocsInSegment = numDocs / 10 + random().nextInt(numDocs / 10);
+
+    for (int i = 1; i <= numDocs; ++i) {
+      final Document doc = new Document();
+      writer.addDocument(doc);
+      if (multipleSegments && (i % numDocsInSegment == 0)) {
+        writer.flush();
+      }
+    }
+    writer.flush();
+
+    IndexReader reader = DirectoryReader.open(writer);
+    IndexSearcher searcher = newSearcher(reader);
+    int visitedHits = 0;
+    ScoreDoc after = null;
+    while (visitedHits < numDocs) {
+      int batch = 1 + random().nextInt(500);
+      Query query = new MatchAllDocsQuery();
+      TopDocs topDocs = searcher.searchAfter(after, query, batch, new Sort(FIELD_DOC));
+      int expectedHits = Math.min(numDocs - visitedHits, batch);
+      assertEquals(expectedHits, topDocs.scoreDocs.length);
+      after = topDocs.scoreDocs[expectedHits - 1];
+      for (int i = 0; i < topDocs.scoreDocs.length; i++) {
+        assertEquals(visitedHits, topDocs.scoreDocs[i].doc);
+        visitedHits++;
+      }
+    }
+    assert (visitedHits == numDocs);

Review comment:
       assertEquals instead?




-- 
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-unsubscribe@lucene.apache.org

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



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