Skip to content

Commit 3724ebb

Browse files
authored
SOLR-18100: Improve Combined Query Feature documentation (#4144)
1 parent 7b0208d commit 3724ebb

1 file changed

Lines changed: 68 additions & 24 deletions

File tree

solr/solr-ref-guide/modules/query-guide/pages/json-combined-query-dsl.adoc

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,42 @@ It is extending JSON Query DSL ultimately enabling Hybrid Search.
2525
This feature is currently unsupported for grouping and Cursors.
2626
====
2727

28+
[IMPORTANT]
29+
====
30+
This feature works in both Standalone and SolrCloud modes and always performs distributed search execution.
31+
In Standalone (user-managed) mode, shard URLs must be explicitly allow-listed using the *allowUrls* parameter, otherwise Solr returns HTTP 403. For example:
32+
33+
```
34+
"-Dsolr.security.allow.urls=http://localhost:8983/solr/"
35+
```
36+
37+
====
38+
39+
== Configuration Requirements
40+
41+
Combined Query Feature has a separate handler with class `solr.CombinedQuerySearchHandler` which can be configured as below:
42+
43+
```
44+
<requestHandler name="/search" class="solr.CombinedQuerySearchHandler">
45+
.....
46+
</requestHandler>
47+
```
48+
49+
In addition, the `QueryComponent` has been extended to create a new `CombinedQueryComponent`, which must be declared as a search component:
50+
```
51+
<searchComponent class="solr.CombinedQueryComponent" name="combined_query">
52+
<int name="maxCombinerQueries">2</int>
53+
</searchComponent>
54+
```
55+
56+
57+
The Search Component also accepts parameters as below:
58+
59+
`maxCombinerQueries`::
60+
This parameter can be set to enforce an upper limit on the number of queries defined in `combiner.query`.
61+
It defaults to `5` if not set.
62+
63+
2864
== Query DSL Structure
2965
The query structure is similar to JSON Query DSL except for how multiple queries are defined along with their parameters.
3066
@@ -71,37 +107,45 @@ Below is a sample JSON query payload:
71107
}
72108
```
73109
74-
== Search Handler Configuration
75-
76-
Combined Query Feature has a separate handler with class `solr.CombinedQuerySearchHandler` which can be configured as below:
77-
78-
```
79-
<requestHandler name="/search" class="solr.CombinedQuerySearchHandler">
80-
.....
81-
</requestHandler>
82-
```
83-
84-
The Search Handler also accepts parameters as below:
110+
== Combiner Algorithm Plugin
85111
86-
`maxCombinerQueries`::
87-
This parameter can be set to put upper limit check on the maximum number of queries can be executed defined in `combiner.query`.
88-
It defaults to `5` if not set.
112+
As mentioned xref:json-combined-query-dsl.adoc#query-dsl-structure[above], custom algorithms can be configured to combine the results across multiple queries using a https://solr.apache.org/guide/solr/latest/configuration-guide/solr-plugins.html[Solr plugin].
89113
90-
=== Combiner Algorithm Plugin
114+
The class to implement the custom logic has to extend `org.apache.solr.handler.component.combine.QueryAndResponseCombiner`, which is an abstract base class that provides a framework for implementing various algorithms used to merge ranked lists and shard documents.
91115
92-
As mentioned xref:json-combined-query-dsl.adoc#query-dsl-structure[above], custom algorithms can be configured to combine the results across multiple queries.
93-
The Combined Query Search Handler definition takes parameter `combiners` where a custom class can be used to define the algorithm by giving a name and the parameters required.
116+
The Combined Query Component definition takes the `combiners` parameter, where the custom class can be declared by specifying a name and the custom parameters required by the custom algorithm.
94117
95-
Example of the Search Handler as below:
118+
Example of the Search Component as below:
96119
```
97120
<searchComponent class="solr.CombinedQueryComponent" name="combined_query">
98-
<int name="maxCombinerQueries">2</int>
121+
<int name="maxCombinerQueries">2</int>
99122
<lst name="combiners">
100-
<lst name="customAlgorithm">
101-
<str name="class">org.apache.solr.search.combine.CustomCombiner</str>
102-
<int name="var1">35</int>
103-
<str name="var2">customValue</str>
123+
<lst name="customAlgorithm">
124+
<str name="class">org.apache.solr.handler.component.combine.CustomCombiner</str>
125+
<int name="customParam1">35</int>
126+
<str name="customParam2">customValue</str>
104127
</lst>
105128
</lst>
106-
</searchComponent>
129+
</searchComponent>
107130
```
131+
132+
Then, when executing the combined query, the only thing that changes in the JSON query payload is the value specified in the `combiner.algorithm` parameter:
133+
134+
```
135+
...
136+
"params": {
137+
"combiner": true,
138+
"combiner.query": ["lexical1", "vector"],
139+
"combiner.algorithm": "customAlgorithm"
140+
}
141+
...
142+
```
143+
144+
In this case, `customAlgorithm` is specified which is the name defined in the configuration; the RRF-specific parameters do not need to be provided.
145+
146+
== Additional Resources
147+
148+
Blog posts:
149+
150+
* https://sease.io/2026/03/hybrid-search-with-reciprocal-rank-fusion-in-apache-solr.html[Hybrid Search with Reciprocal Rank Fusion in Apache Solr]
151+
* https://sease.io/2026/03/hybrid-search-using-a-custom-algorithm-in-apache-solr.html[Hybrid Search using a Custom Algorithm in Apache Solr]

0 commit comments

Comments
 (0)