ercsonusharma commented on code in PR #4277:
URL: https://github.com/apache/solr/pull/4277#discussion_r3084423776


##########
solr/core/src/java/org/apache/solr/handler/component/combine/QueryAndResponseCombiner.java:
##########
@@ -87,14 +122,53 @@ public static QueryResult simpleCombine(List<QueryResult> 
queryResults) {
             combinedResultsLength,
             combinedResultsDocIds,
             combinedResultScores,
-            Math.max(combinedResultsLength, totalMatches),
+            Math.max(combinedResultsLength, totalMatches - removedByCollapse),
             combinedResultScores.length > 0 ? combinedResultScores[0] : 0,
             TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO);
     combinedQueryResults.setDocList(combinedResultSlice);
     combinedQueryResults.setDocSet(combinedDocSet);
     return combinedQueryResults;
   }
 
+  /**
+   * Removes collapsed duplicates by delegating to SolrIndexSearcher with the 
CollapsingPostFilter.
+   * Uses a DocSetQuery wrapped with FunctionScoreQuery.boostByValue to 
preserve original scores
+   * from combined sub-queries, then applies the collapse filter to determine 
surviving doc IDs.
+   *
+   * <p>This leverages Solr's native collapse infrastructure instead of 
manually reading DocValues.
+   */
+  private static DocSet removeCollapsedDuplicatesViaSearcher(
+      CollapsingPostFilter collapseFilter,
+      SolrIndexSearcher searcher,
+      Map<Integer, Float> uniqueDocIds,

Review Comment:
   ah, Thanks for catching this. It shouldn't be using the docSet from the 
individual sub-queries rather it should be built on top of docList. I have made 
this change now.



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