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


##########
lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java:
##########
@@ -1678,8 +1784,54 @@ public ShardSearcher(LeafReaderContext ctx, 
IndexReaderContext parent) {
       this.ctx = ctx;
     }
 
-    public void search(Weight weight, Collector collector) throws IOException {
+    @Override
+    public <C extends Collector, T> T search(Query query, CollectorManager<C, 
T> collectorManager)
+        throws IOException {
+      final Weight weight = createWeight(rewrite(query), ScoreMode.COMPLETE, 
1);

Review Comment:
   nit: the score mode should be retrieved from one of the collectors. I 
believe we used to do that earlier, now it's hardcoded, which may force 
complete scoring when not necessary.



##########
lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java:
##########
@@ -1471,38 +1589,24 @@ private TopGroups<BytesRef> searchShards(
               + canUseIDV);
     }
     // Run 1st pass collector to get top groups per shard
-    final Weight w =
-        topSearcher.createWeight(
-            topSearcher.rewrite(query),
-            groupSort.needsScores() || docSort.needsScores() || getMaxScores
-                ? ScoreMode.COMPLETE
-                : ScoreMode.COMPLETE_NO_SCORES,
-            1);
     final List<Collection<SearchGroup<BytesRef>>> shardGroups = new 
ArrayList<>();
-    List<FirstPassGroupingCollector<?>> firstPassGroupingCollectors = new 
ArrayList<>();
-    FirstPassGroupingCollector<?> firstPassCollector = null;
-
     String groupField = "group";
 
+    // TermGroupSelector or ValueSourceGroupSelector
+    final boolean isTermGroupSelector = random().nextBoolean();
+
     for (int shardIDX = 0; shardIDX < subSearchers.length; shardIDX++) {
+      final FirstPassGroupingCollectorManager<?> 
firstPassGroupingCollectorManager =
+          createFirstPassCollectorManager(
+              isTermGroupSelector, groupField, groupSort, 0, groupOffset + 
topNGroups);
 
-      // First shard determines whether we use IDV or not;
-      // all other shards match that:
-      if (firstPassCollector == null) {
-        firstPassCollector =
-            createRandomFirstPassCollector(groupField, groupSort, groupOffset 
+ topNGroups);
-      } else {
-        firstPassCollector =
-            createFirstPassCollector(
-                groupField, groupSort, groupOffset + topNGroups, 
firstPassCollector);
-      }
       if (VERBOSE) {
         System.out.println("  shard=" + shardIDX + " groupField=" + 
groupField);
-        System.out.println("    1st pass collector=" + firstPassCollector);
+        System.out.println("    1st pass collector manager=" + 
firstPassGroupingCollectorManager);
       }
-      firstPassGroupingCollectors.add(firstPassCollector);
-      subSearchers[shardIDX].search(w, firstPassCollector);
-      final Collection<SearchGroup<BytesRef>> topGroups = 
getSearchGroups(firstPassCollector, 0);
+      final Collection<SearchGroup<BytesRef>> topGroups =
+          toByteRefSearchGroups(
+              subSearchers[shardIDX].search(query, 
firstPassGroupingCollectorManager));
       if (topGroups != null) {

Review Comment:
   this null check is perhaps now redundant? Can you double check?



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