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


##########
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:
   Sorry, I missed this earlier, wasn't this comparison valuable to check that 
the large hits collector returns the same hits as the regular collector? We can 
now use a collector manager for the large collection too, while we could not 
before?



##########
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:
   And maybe these could be replaced by checking the top docs returned by the 
collector manager?



##########
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:
   I feel like this test, as well as the following two tests, no longer verify 
what it meant to verify in the first place, which is the PQ building. That 
requires direct access to the collector though. That can be done via a package 
private getCollectors method exposed by the collector manager, that allows us 
to introspect the created collectors?



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