Skip to content

SOLR-18195: Support for Collapse Results in Combined Query Component#4277

Open
ercsonusharma wants to merge 8 commits intoapache:mainfrom
ercsonusharma:feat_combined_query_collapse
Open

SOLR-18195: Support for Collapse Results in Combined Query Component#4277
ercsonusharma wants to merge 8 commits intoapache:mainfrom
ercsonusharma:feat_combined_query_collapse

Conversation

@ercsonusharma
Copy link
Copy Markdown
Contributor

@ercsonusharma ercsonusharma commented Apr 11, 2026

https://issues.apache.org/jira/browse/SOLR-18195

With reference to previous new Query Component Feature: https://issues.apache.org/jira/browse/SOLR-17319

Description

When using {!collapse} with CombinedQueryComponent (hybrid search / RRF), duplicate documents appear in the result set for the same collapse field value. Each sub-query independently collapses correctly via CollapsingPostFilter, but simpleCombine() merges results by Lucene doc ID only - it has no awareness of the collapse field. Different sub-queries may select different group heads for the same field value, and both survive the merge.

However it is well know limitation that :[ "In order to use these features with SolrCloud, the documents must be located on the same shard."|https://solr.apache.org/guide/solr/latest/query-guide/collapse-and-expand-results.html]

Solution

Removing collapsed duplicates by delegating to SolrIndexSearcher with the CollapsingPostFilter by forming the query using PrecomputedScoreQuery to preserve original scores with filter on the docSet from combined sub-queries. The duplicates are removed honouring the collapse query criteria.

Tests

Added comprehensive test with Collapse Query.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant