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