epotyom commented on code in PR #13568:
URL: https://github.com/apache/lucene/pull/13568#discussion_r1677872262


##########
lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:
##########
@@ -630,27 +630,47 @@ private TopFieldDocs searchAfter(
    */
   public <C extends Collector, T> T search(Query query, CollectorManager<C, T> 
collectorManager)
       throws IOException {
-    final C firstCollector = collectorManager.newCollector();
+    CollectorOwner<C, T> collectorOwner = 
CollectorOwner.hire(collectorManager);
+    final C firstCollector = collectorOwner.newCollector();
     query = rewrite(query, firstCollector.scoreMode().needsScores());
     final Weight weight = createWeight(query, firstCollector.scoreMode(), 1);
-    return search(weight, collectorManager, firstCollector);
+    search(weight, collectorOwner, firstCollector);
+    return collectorOwner.reduce();
   }
 
-  private <C extends Collector, T> T search(
-      Weight weight, CollectorManager<C, T> collectorManager, C 
firstCollector) throws IOException {
+  /**
+   * Lower-level search API. Search all leaves using the given {@link 
CollectorOwner}, without
+   * calling {@link CollectorOwner#reduce()} so that clients can reduce and 
read results themselves.
+   *
+   * <p>TODO: CollectorOwner has getResults method now (not yet used by 
anything), so maybe it's ok
+   * to call reduce in this method?
+   *
+   * @lucene.experimental
+   */
+  public <C extends Collector> void searchNoReduce(Query query, 
CollectorOwner<C, ?> collectorOwner)
+      throws IOException {
+    final C firstCollector = collectorOwner.newCollector();
+    query = rewrite(query, firstCollector.scoreMode().needsScores());
+    final Weight weight = createWeight(query, firstCollector.scoreMode(), 1);
+    search(weight, collectorOwner, firstCollector);
+  }
+
+  private <C extends Collector> void search(
+      Weight weight, CollectorOwner<C, ?> collectorOwner, C firstCollector) 
throws IOException {

Review Comment:
   Oh, will do - sorry!



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