ercsonusharma commented on code in PR #5172:
URL: https://github.com/apache/solr/pull/5172#discussion_r4296815997
##########
solr/solr-ref-guide/modules/query-guide/pages/json-combined-query-dsl.adoc:
##########
@@ -79,6 +79,9 @@ The query structure is similar to JSON Query DSL except for
how multiple queries
[NOTE]
====
Consider setting `shards.rows` to at least your deepest expected `start +
rows` to enlarge the per-shard candidate pool used for fusion, giving more
consistent ordering across pages.
+
+`numFound` in the response is the number of distinct documents in the fused
result.
Review Comment:
Suggest: "numFound is the number of distinct documents in the fused result
when numFoundExact is true. Otherwise it is a lower bound: at least the largest
sub-query's match count."
##########
solr/core/src/test/org/apache/solr/handler/component/DistributedCombinedQueryComponentTest.java:
##########
@@ -162,6 +162,47 @@ public void testCombinedQueries() throws Exception {
assertEquals(5, rsp.getResults().size());
assertFieldValues(rsp.getResults(), id, "5", "7", "2", "6", "3");
+ // both queries match 6 docs, overlapping on docs 5 and 6, so the fused
result has 10 distinct
+ // docs; numFound is that distinct count, exact since no list was truncated
+ rsp =
+ query(
+ "/search",
+ params(
+ CommonParams.JSON,
+ """
+ {
+ "queries": {
+ "lexical1": {"lucene": {"query": "id:(1^=6 OR 2^=5 OR 3^=4
OR 4^=3 OR 5^=2 OR 6^=1)"}},
+ "lexical2": {"lucene": {"query": "id:(5^=6 OR 6^=5 OR 7^=4
OR 8^=3 OR 9^=2 OR 10^=1)"}}
+ },
+ "limit": 10,
+ "fields": ["id", "score"],
+ "params": {"combiner": true, "combiner.query": ["lexical1",
"lexical2"]}
+ }"""));
+ assertEquals(10, rsp.getResults().getNumFound());
+ assertEquals(Boolean.TRUE, rsp.getResults().getNumFoundExact());
+
+ // same queries, but the fusion pool (start + rows = 4) truncates each
6-match list to its
+ // top 4, so numFound is the fused pool size and is reported inexact
+ rsp =
+ query(
+ "/search",
+ params(
+ CommonParams.JSON,
+ """
+ {
+ "queries": {
+ "lexical1": {"lucene": {"query": "id:(1^=6 OR 2^=5 OR 3^=4
OR 4^=3 OR 5^=2 OR 6^=1)"}},
+ "lexical2": {"lucene": {"query": "id:(5^=6 OR 6^=5 OR 7^=4
OR 8^=3 OR 9^=2 OR 10^=1)"}}
+ },
+ "limit": 4,
+ "fields": ["id", "score"],
+ "params": {"combiner": true, "combiner.query": ["lexical1",
"lexical2"]}
+ }"""));
+ assertEquals(4, rsp.getResults().size());
+ assertEquals(8, rsp.getResults().getNumFound());
Review Comment:
The true union is 10 and the largest sub-query has 6. Asserting 8 locks the
test to the pool size, which changes with limit. With the suggested change this
would assert the max, at least 6, and stay `numFoundExact == false`.
##########
solr/core/src/test/org/apache/solr/handler/component/CombinedQueryComponentTest.java:
##########
@@ -196,7 +224,8 @@ public void testCombinerPlugin() throws Exception {
+ "\"fields\":[\"id\",\"score\",\"title\"],"
+
"\"params\":{\"combiner\":true,\"combiner.algorithm\":test,\"combiner.query\""
+
":[\"lexical1\",\"lexical2\"],\"debug\":[\"results\"]}}"));
- assertEquals(10, rsp.getResults().getNumFound());
+ // the test combiner fuses to an empty list, so numFound reflects the
fused result
+ assertEquals(0, rsp.getResults().getNumFound());
Review Comment:
10 docs match here, so numFound: 0 documents the pool-size behaviour rather
than a count we want.
--
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]