Hi Justin,

Thanks for the writeup. I actually ran into the same bug a few days back
while working on the RRF weights change (
https://github.com/apache/solr/pull/5119), so this was on my list to fix
anyway.

The cause is in CombinedQueryComponent.mergeIds: numFound ends up as the
bigger sub-query's count instead of the fused one, and the numFoundExact
check is inverted, which is why your all-exact example shows false.

I have filed a JIRA(https://issues.apache.org/jira/browse/SOLR-18550) and
will raise a PR on main with the fix shortly. Your repro would make a good
test case, so I'll fold it in. Happy to review with you or have you review
the patch. I've credited you as the reporter in the JIRA and the changelog.


Puneet

On Fri, Oct 16, 2026 at 2:28 AM Justin Michael Coyne via dev <
[email protected]> wrote:

> I was working with CombinedQuerySearchHandler (in solr 10.1.0.rc2) today
> and noticed that it reports numFound as the largest sub-query's hit count,
> not the size of the fused result. Shouldn't it instead be the number of
> distinct documents in the combined result, which is the union of the
> sub-queries?
>
> Here's a reproduction:
>
> SOLR=http://localhost:8983/solr/demo
>
> curl -s "$SOLR/config" -H 'Content-Type: application/json' -d '{
> "add-searchcomponent": {"name": "combined_query", "class":
> "solr.CombinedQueryComponent"},
> "add-requesthandler": {"name": "/hybrid", "class":
> "solr.CombinedQuerySearchHandler"}
> }'
> 3 cat docs, 2 dog docs, no overlap
> curl -s "$SOLR/update?commit=true" -H 'Content-Type: application/json' -d
> '[
> {"id": "1", "subject_s": "cat"},
> {"id": "2", "subject_s": "cat"},
> {"id": "3", "subject_s": "cat"},
> {"id": "4", "subject_s": "dog"},
> {"id": "5", "subject_s": "dog"}
> ]'
>
>
> curl -s "$SOLR/hybrid" -H 'Content-Type: application/json' -d '{
> "queries": {
> "cats": {"lucene": {"query": "subject_s:cat"}},
> "dogs": {"lucene": {"query": "subject_s:dog"}}
> },
> "params": {
> "combiner": true,
> "combiner.query": ["cats", "dogs"],
> "combiner.algorithm": "rrf",
> "fl": "id",
> "rows": 10
> }
> }'
>
>
> Expected
> `numFound: 5`, the same as `/select?q=subject_s:cat OR subject_s:dog`,
> which returns `numFound: 5, numFoundExact: true`.
> Actual
> {"response": {"numFound": 3, "start": 0, "numFoundExact": false,
> "docs": [{"id": "4"}, {"id": "1"}, {"id": "5"}, {"id": "2"}, {"id": "3"}]}}
>
> The response returns five documents but reports `numFound: 3`.
>

Reply via email to