gaobinlong commented on code in PR #15660:
URL: https://github.com/apache/lucene/pull/15660#discussion_r3273039478


##########
lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestLargeNumHitsTopDocsCollector.java:
##########
@@ -90,94 +90,102 @@ public void testInvalidRequestedHitCount() {
     }
   }
 
-  public void testTopDocs() throws IOException {
-    IndexSearcher searcher = newSearcher(reader);
+  public void testTopDocs() {
     LargeNumHitsTopDocsCollector largeCollector = new 
LargeNumHitsTopDocsCollector(15);
-    TopScoreDocCollectorManager regularCollectorManager =
-        new TopScoreDocCollectorManager(15, Integer.MAX_VALUE);
-
-    searcher.search(testQuery, largeCollector);
-    TopDocs topDocs = searcher.search(testQuery, regularCollectorManager);
-
-    assertEquals(largeCollector.totalHits, topDocs.totalHits.value());
 
     IllegalArgumentException expected =
         expectThrows(IllegalArgumentException.class, () -> 
largeCollector.topDocs(-1));
-
     assertTrue(expected.getMessage().contains("Number of hits requested must 
not be negative"));
 
     assertEquals(EMPTY_TOPDOCS, largeCollector.topDocs(0));
-    assertEquals(largeCollector.totalHits, 
largeCollector.topDocs(35_000).totalHits.value());

Review Comment:
   Covered by runNumHits.



##########
lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestLargeNumHitsTopDocsCollector.java:
##########
@@ -90,94 +90,102 @@ public void testInvalidRequestedHitCount() {
     }
   }
 
-  public void testTopDocs() throws IOException {
-    IndexSearcher searcher = newSearcher(reader);
+  public void testTopDocs() {
     LargeNumHitsTopDocsCollector largeCollector = new 
LargeNumHitsTopDocsCollector(15);
-    TopScoreDocCollectorManager regularCollectorManager =
-        new TopScoreDocCollectorManager(15, Integer.MAX_VALUE);
-
-    searcher.search(testQuery, largeCollector);
-    TopDocs topDocs = searcher.search(testQuery, regularCollectorManager);

Review Comment:
   That is already covered by runNumHits(), I've changed this method name to 
testHowMany to ensure no confusion.



##########
lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestLargeNumHitsTopDocsCollector.java:
##########
@@ -90,94 +90,102 @@ public void testInvalidRequestedHitCount() {
     }
   }
 
-  public void testTopDocs() throws IOException {
-    IndexSearcher searcher = newSearcher(reader);
+  public void testTopDocs() {
     LargeNumHitsTopDocsCollector largeCollector = new 
LargeNumHitsTopDocsCollector(15);
-    TopScoreDocCollectorManager regularCollectorManager =
-        new TopScoreDocCollectorManager(15, Integer.MAX_VALUE);
-
-    searcher.search(testQuery, largeCollector);
-    TopDocs topDocs = searcher.search(testQuery, regularCollectorManager);
-
-    assertEquals(largeCollector.totalHits, topDocs.totalHits.value());
 
     IllegalArgumentException expected =
         expectThrows(IllegalArgumentException.class, () -> 
largeCollector.topDocs(-1));
-
     assertTrue(expected.getMessage().contains("Number of hits requested must 
not be negative"));
 
     assertEquals(EMPTY_TOPDOCS, largeCollector.topDocs(0));
-    assertEquals(largeCollector.totalHits, 
largeCollector.topDocs(35_000).totalHits.value());
   }
 
   public void testNoPQBuild() throws IOException {
     IndexSearcher searcher = newSearcher(reader);
-    LargeNumHitsTopDocsCollector largeCollector = new 
LargeNumHitsTopDocsCollector(250_000);
+    LargeNumHitsTopDocsCollectorManager largeCollectorManager =
+        new LargeNumHitsTopDocsCollectorManager(250_000);
     TopScoreDocCollectorManager regularCollectorManager =
         new TopScoreDocCollectorManager(reader.numDocs(), Integer.MAX_VALUE);
 
-    searcher.search(testQuery, largeCollector);
-    TopDocs topDocs = searcher.search(testQuery, regularCollectorManager);
-
-    assertEquals(largeCollector.totalHits, topDocs.totalHits.value());
+    TopDocs largeTopDocs = searcher.search(testQuery, largeCollectorManager);
+    TopDocs regularTopDocs = searcher.search(testQuery, 
regularCollectorManager);
 
-    assertNull(largeCollector.pq);
-    assertNull(largeCollector.pqTop);
+    assertEquals(largeTopDocs.totalHits.value(), 
regularTopDocs.totalHits.value());
+    CheckHits.checkEqual(testQuery, largeTopDocs.scoreDocs, 
regularTopDocs.scoreDocs);

Review Comment:
   Done that, but for `testPQBuild()`, which verifies that PR is built when 
requestHitCount is less than totalHits, we have to make the `totalHits` 
variable in collector package private so that we can filter the no-hit 
collector, does that make sense?



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