squallsama opened a new pull request, #5366: URL: https://github.com/apache/solr/pull/5366
https://issues.apache.org/jira/browse/SOLR-18676 # Description Combined Query always forces distributed search, and the sub-query lists are fused only in `CombinedQueryComponent.mergeIds` on the coordinator. Outside SolrCloud this means: * Embedded Solr cannot run a combined query at all: with no `shards` parameter, `HttpShardHandler.prepDistributed` builds the shard URL from `req.getHttpSolrCall()`, which is null there. * Standalone Solr sends every combined query to itself over HTTP and needs its own URL allow-listed. * With `distrib=false`, `process()` returns `simpleCombine`: a union in hash order, with no RRF and no sort. # Solution * `CombinedQuerySearchHandler` forces distributed search only in SolrCloud. Elsewhere a request that names no shards (and does not set `distrib=true`) is served by the core that receives it. * `CombinedQueryComponent.process()` fuses the lists on that core. It is `mergeIds` over the lists of a single shard and shares its code (`combineAndSort`): union and collapse across sub-queries, the configured combiner, the request's sort, `numFound`/`numFoundExact`, combiner explanations. Each sub-query is fetched to `start + rows`, or `shards.rows` when given, as a shard is. The DocSet for facets is the union of the sub-queries'. * `QueryComponent.computeFieldSortValues(DocList, SortSpec, searcher)` is extracted from `doFieldSortValues` so the sort values can be computed for a given sort. Two bugs of the distributed path came up while comparing local and distributed answers, and are fixed here (happy to split them out): 1. A single-pass distributed combined query (e.g. `fl=id,score`) returned one sub-query's raw score instead of the fused score. `CombinedQueryComponent` now overrides `returnFields` to set the fused score. 2. Elevation from `elevate.xml` that matches the text of only some sub-queries failed the request with `IndexOutOfBoundsException`, SolrCloud included: `QueryElevationComponent` copies the first sub-query's elevated `SortSpec` onto the request, but each sub-query's sort values were computed for its own sort, which lacks `_elevate_`. They are now computed for the request's sort. Behaviour change: standalone Solr no longer distributes a combined query to itself (no allow-listing of its own URL needed), and `distrib=false` returns the fused, sorted result. SolrCloud is unchanged. Ties in fused score keep the existing distributed order. This change was written with the help of an AI coding assistant (Claude Code), with `AGENTS.md` in context; I reviewed the code and the test results. # Tests * `CombinedQuerySingleCoreTest` (new): every request runs on embedded Solr, on standalone Solr, and on standalone Solr with `shards=` pointing at itself; the three answers must be identical (docs and fields, scores, numFound/numFoundExact, start, maxScore, facets, JSON facets, stats, highlighting, expanded, combiner explanations, query boosting). It covers lexical + knn hybrid, `vectorSimilarity`, edismax/func sub-queries, JSON DSL and plain params, RRF `k` and weights, a plugin combiner, invalid weights/algorithm/query limit, grouping and cursor rejection, paging and `shards.rows`, sorts, filters, `fl` variants, facets, elevation (`elevateIds`, `excludeIds`, `elevate.xml`), collapse and expand, debug. It also checks that standalone sends no shard request. * `CombinedQueryEmbeddedTest` (new): fused order and scores against hand-computed RRF on embedded Solr. * `CombinedQueryComponentTest` and `DistributedCombinedQueryComponentTest` compare a control core with a distributed search; the control core now fuses locally, so they check the same equivalence (the former skips `maxScore` and `debug`, which a single core reports differently for any query). * Also run: all `CombinedQuery*`, `combine.*`, `TestDistributedSearch`, `DistributedQueryComponentOptimizationTest`, `CursorPagingTest`, `DistribCursorPagingTest`, `QueryElevationComponentTest`, `DistributedQueryElevationComponentTest`; the combined-query suites with five random seeds; `gradlew :solr:core:check -x test`. # Checklist Please review the following and check all that apply: - [ ] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
