Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bf3cd5d
Combined Query Feature for Multi Query Execution
Jun 15, 2025
182bec9
Tests: Combined Query Feature for Multi Query Execution
Jun 17, 2025
b884f0e
Tests: Combined Query Feature for Multi Query Execution
Jun 24, 2025
29e8aea
Tests: Combined Query Feature for Multi Query Execution
Jun 25, 2025
c113799
Improve: Fix typo
ercsonusharma Jul 4, 2025
3600ed3
Tests: Fix errors
ercsonusharma Jul 4, 2025
9b0c76e
Review comments: implementation
ercsonusharma Jul 5, 2025
a841bc7
Code review changes
ercsonusharma Jul 12, 2025
91f8e09
Code review changes
ercsonusharma Jul 12, 2025
cace1f7
Code review changes
ercsonusharma Jul 12, 2025
299db43
Code review changes
ercsonusharma Jul 13, 2025
840070e
Code review changes
ercsonusharma Jul 13, 2025
d2feefc
Improvement and fixes
ercsonusharma Jul 16, 2025
89f63a9
Review comments impl
ercsonusharma Jul 26, 2025
d821abb
Build fix
ercsonusharma Jul 28, 2025
8041d66
Added documentation
ercsonusharma Aug 5, 2025
397dbb3
Fix for lucene upgrade
ercsonusharma Aug 8, 2025
d8b5588
Doc improv for cursors
ercsonusharma Aug 14, 2025
ec0b9cb
review comment implementation
ercsonusharma Aug 18, 2025
d6fd190
review comment implementation
ercsonusharma Aug 19, 2025
86933bc
review comment implementation
ercsonusharma Aug 20, 2025
b164979
doc update
ercsonusharma Aug 27, 2025
85f2cf9
added more test
ercsonusharma Aug 29, 2025
a4a26aa
abstract QueryComponent.mergeIds' ShardDoc processing
cpoerschke Aug 29, 2025
7fe997c
add missing @Override annotations
cpoerschke Aug 29, 2025
bcd1c3b
make DefaultShardDocQueue an anonymous class
cpoerschke Sep 1, 2025
787a016
Merge branch 'apache:main' into QueryComponent-mergeIds
cpoerschke Sep 1, 2025
7e0727c
Merge remote-tracking branch 'github_cpoerschke/QueryComponent-mergeI…
cpoerschke Sep 1, 2025
4dcbb57
dev increment: add uniqueDoc map-and-logic to ShardDocQueue
cpoerschke Sep 1, 2025
8a65023
review comment fix
ercsonusharma Sep 2, 2025
006b8c2
micro dev increment: replace unnecessary local resultSize use in Quer…
cpoerschke Sep 2, 2025
771089b
dev increment: factor out ShardDocQueue.resultIds method
cpoerschke Sep 2, 2025
460e8cd
dev increment: remove no-longer-used ShardDocQueue.(pop,size) methods
cpoerschke Sep 2, 2025
ac85d2f
review comment fix
ercsonusharma Sep 3, 2025
7b0593c
review comment fix
ercsonusharma Sep 3, 2025
c03c0f7
review comment enhancement
ercsonusharma Sep 3, 2025
a52dd22
simplification/consolidation: protected QueryComponent.newShardDocQue…
cpoerschke Sep 3, 2025
195f3f1
factor out protected QueryComponent.setResultIdsAndResponseDocs method
cpoerschke Sep 3, 2025
c1f5501
review comment enhancement
ercsonusharma Sep 3, 2025
3649d3e
Merge branch 'feat_combined_query' of https://github.com/ercsonusharm…
ercsonusharma Sep 3, 2025
4eedbed
refactor to reduce cyclometric complexity
ercsonusharma Sep 3, 2025
0990e7f
review comment fixes
ercsonusharma Sep 4, 2025
14ff5e1
debug params fix and rrf shard sort order
ercsonusharma Sep 4, 2025
bd637b7
test cases fix and rrf shard sort order
ercsonusharma Sep 5, 2025
2958599
introducing combiner methods as pre and post
ercsonusharma Sep 7, 2025
c3e44c3
distrib forced and doc update
ercsonusharma Sep 10, 2025
e2dfcef
distrib forced fix
ercsonusharma Sep 11, 2025
d4b34fc
distrib forced fix
ercsonusharma Sep 12, 2025
3fe93b8
test fix
ercsonusharma Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.handler.component;

import java.util.ArrayList;
import java.util.List;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;

/**
* The CombinedQueryResponseBuilder class extends the ResponseBuilder class and is responsible for
* building a combined response for multiple SearchComponent objects. It orchestrates the process of
* constructing the SolrQueryResponse by aggregating results from various components.
*/
public class CombinedQueryResponseBuilder extends ResponseBuilder {

public final List<ResponseBuilder> responseBuilders = new ArrayList<>();

/**
* Constructs a CombinedQueryResponseBuilder instance.
*
* @param req the SolrQueryRequest object containing the query parameters and context.
* @param rsp the SolrQueryResponse object to which the combined results will be added.
* @param components a list of SearchComponent objects that will be used to build the response.
*/
public CombinedQueryResponseBuilder(
SolrQueryRequest req, SolrQueryResponse rsp, List<SearchComponent> components) {
super(req, rsp, components);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.handler.component;

import java.util.ArrayList;
import java.util.List;
import org.apache.solr.common.params.CombinerParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.facet.FacetModule;

/**
* The CombinedQuerySearchHandler class extends the SearchHandler and provides custom behavior for
* handling combined queries. It overrides methods to create a response builder based on the {@link
* CombinerParams#COMBINER} parameter and to define the default components included in the search
* configuration.
*/
public class CombinedQuerySearchHandler extends SearchHandler {

/**
* Overrides the default response builder creation method. This method checks if the {@link
* CombinerParams#COMBINER} parameter is set to true in the request. If it is, it returns an
* instance of {@link CombinedQueryResponseBuilder}, otherwise, it returns an instance of {@link
* ResponseBuilder}.
*
* @param req the SolrQueryRequest object
* @param rsp the SolrQueryResponse object
* @param components the list of SearchComponent objects
* @return the appropriate ResponseBuilder instance based on the CombinerParams.COMBINER parameter
*/
@Override
protected ResponseBuilder newResponseBuilder(
SolrQueryRequest req, SolrQueryResponse rsp, List<SearchComponent> components) {
if (req.getParams().getBool(CombinerParams.COMBINER, false)) {
return new CombinedQueryResponseBuilder(req, rsp, components);
}
return new ResponseBuilder(req, rsp, components);
}

/**
* Overrides the default components and returns a list of component names that are included in the
* default configuration.
*
* @return a list of component names
*/
@Override
@SuppressWarnings("unchecked")
protected List<String> getDefaultComponents() {
List<String> names = new ArrayList<>(9);
names.add(CombinedQueryComponent.COMPONENT_NAME);
names.add(FacetComponent.COMPONENT_NAME);
names.add(FacetModule.COMPONENT_NAME);
names.add(MoreLikeThisComponent.COMPONENT_NAME);
names.add(HighlightComponent.COMPONENT_NAME);
names.add(StatsComponent.COMPONENT_NAME);
names.add(DebugComponent.COMPONENT_NAME);
names.add(ExpandComponent.COMPONENT_NAME);
names.add(TermsComponent.COMPONENT_NAME);
return names;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.search.combine;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CombinerParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.component.ShardDoc;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.QueryResult;
import org.apache.solr.search.SolrIndexSearcher;

/**
* The QueryAndResponseCombiner class is an abstract base class for combining query results and
* shard documents. It provides a framework for different algorithms to be implemented for merging
* ranked lists and shard documents.
*/
public abstract class QueryAndResponseCombiner {

public abstract void init(NamedList<?> args);

/**
* Combines multiple ranked lists into a single QueryResult.
*
* @param rankedLists a list of ranked lists to be combined
* @param solrParams params to be used when provided at query time
* @return a new QueryResult containing the combined results
* @throws IllegalArgumentException if the input list is empty
*/
public abstract QueryResult combine(List<QueryResult> rankedLists, SolrParams solrParams);

/**
* Combines shard documents based on the provided map.
*
* @param shardDocMap a map where keys represent shard IDs and values are lists of ShardDocs for
* each shard
* @param solrParams params to be used when provided at query time
* @return a combined list of ShardDocs from all shards
*/
public abstract List<ShardDoc> combine(
Map<String, List<ShardDoc>> shardDocMap, SolrParams solrParams);

/**
* Retrieves a list of explanations for the given queries and results.
*
* @param queryKeys the keys associated with the queries
* @param queries the list of queries for which explanations are requested
* @param queryResult the list of QueryResult corresponding to each query
* @param searcher the SolrIndexSearcher used to perform the search
* @param schema the IndexSchema used to interpret the search results
* @param solrParams params to be used when provided at query time
* @return a list of explanations for the given queries and results
* @throws IOException if an I/O error occurs during the explanation retrieval process
*/
public abstract NamedList<Explanation> getExplanations(
String[] queryKeys,
List<Query> queries,
List<QueryResult> queryResult,
SolrIndexSearcher searcher,
IndexSchema schema,
SolrParams solrParams)
throws IOException;

/**
* Retrieves an implementation of the QueryAndResponseCombiner based on the specified algorithm.
*
* @param requestParams the SolrParams containing the request parameters, including the combiner
* algorithm.
* @param combiners The already initialised map of QueryAndResponseCombiner
* @return an instance of QueryAndResponseCombiner corresponding to the specified algorithm.
* @throws SolrException if an unknown combiner algorithm is specified.
*/
public static QueryAndResponseCombiner getImplementation(
SolrParams requestParams, Map<String, QueryAndResponseCombiner> combiners) {
String algorithm =
requestParams.get(CombinerParams.COMBINER_ALGORITHM, CombinerParams.DEFAULT_COMBINER);
if (combiners.containsKey(algorithm)) {
return combiners.get(algorithm);
}
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST, "Unknown Combining algorithm: " + algorithm);
}
}
Loading
Loading