atris commented on code in PR #3418: URL: https://github.com/apache/solr/pull/3418#discussion_r2195755106
########## solr/core/src/java/org/apache/solr/search/combine/QueryAndResponseCombiner.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.DocList; +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 + * responses. It provides a framework for different algorithms to be implemented for merging ranked + * lists and shard documents. + */ +public abstract class QueryAndResponseCombiner { + + protected int upTo; + + /** + * Constructs a QueryAndResponseCombiner instance. + * + * @param requestParams the SolrParams containing the request parameters. + */ + protected QueryAndResponseCombiner(SolrParams requestParams) { + this.upTo = + requestParams.getInt(CombinerParams.COMBINER_UP_TO, CombinerParams.COMBINER_UP_TO_DEFAULT); + } + + /** + * Combines multiple ranked lists into a single QueryResult. + * + * @param rankedLists a list of ranked lists to be combined + * @return a new QueryResult containing the combined results + * @throws IllegalArgumentException if the input list is empty + */ + public abstract QueryResult combine(List<QueryResult> rankedLists); + + /** + * 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 + * @return a combined list of ShardDocs from all shards + */ + public abstract List<ShardDoc> combine(Map<String, List<ShardDoc>> shardDocMap); + + /** + * 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 resultsPerQuery the list of document lists corresponding to each query + * @param searcher the SolrIndexSearcher used to perform the search + * @param schema the IndexSchema used to interpret the search results + * @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<DocList> resultsPerQuery, + SolrIndexSearcher searcher, + IndexSchema schema) + 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. + * @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) { + String algorithm = + requestParams.get(CombinerParams.COMBINER_ALGORITHM, CombinerParams.RECIPROCAL_RANK_FUSION); + if (algorithm.equals(CombinerParams.RECIPROCAL_RANK_FUSION)) { Review Comment: This is hardcoded - why not have a Plugin interface here, allowing dynamic plugin loaded here? ########## solr/core/src/java/org/apache/solr/search/combine/QueryAndResponseCombiner.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.DocList; +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 + * responses. It provides a framework for different algorithms to be implemented for merging ranked + * lists and shard documents. + */ +public abstract class QueryAndResponseCombiner { + + protected int upTo; + + /** + * Constructs a QueryAndResponseCombiner instance. + * + * @param requestParams the SolrParams containing the request parameters. + */ + protected QueryAndResponseCombiner(SolrParams requestParams) { + this.upTo = + requestParams.getInt(CombinerParams.COMBINER_UP_TO, CombinerParams.COMBINER_UP_TO_DEFAULT); + } + + /** + * Combines multiple ranked lists into a single QueryResult. + * + * @param rankedLists a list of ranked lists to be combined + * @return a new QueryResult containing the combined results + * @throws IllegalArgumentException if the input list is empty + */ + public abstract QueryResult combine(List<QueryResult> rankedLists); + + /** + * 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 + * @return a combined list of ShardDocs from all shards + */ + public abstract List<ShardDoc> combine(Map<String, List<ShardDoc>> shardDocMap); + + /** + * 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 resultsPerQuery the list of document lists corresponding to each query + * @param searcher the SolrIndexSearcher used to perform the search + * @param schema the IndexSchema used to interpret the search results + * @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( Review Comment: Please implement support for debug as well ########## solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java: ########## @@ -0,0 +1,169 @@ +/* + * 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.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.params.CombinerParams; +import org.apache.solr.common.params.CursorMarkParams; +import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.response.BasicResultContext; +import org.apache.solr.response.ResultContext; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.search.DocListAndSet; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.combine.QueryAndResponseCombiner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The CombinedQueryComponent class extends QueryComponent and provides support for executing + * multiple queries and combining their results. + */ +public class CombinedQueryComponent extends QueryComponent { + + public static final String COMPONENT_NAME = "combined_query"; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** + * Overrides the prepare method to handle combined queries. + * + * @param rb the ResponseBuilder to prepare + * @throws IOException if an I/O error occurs during preparation + */ + @Override + public void prepare(ResponseBuilder rb) throws IOException { + if (rb instanceof CombinedQueryResponseBuilder crb) { + SolrParams params = crb.req.getParams(); + String[] queriesToCombineKeys = params.getParams(CombinerParams.COMBINER_QUERY); + for (String queryKey : queriesToCombineKeys) { + final var unparsedQuery = params.get(queryKey); + ResponseBuilder rbNew = new ResponseBuilder(rb.req, new SolrQueryResponse(), rb.components); + rbNew.setQueryString(unparsedQuery); + super.prepare(rbNew); + crb.responseBuilders.add(rbNew); + } + } + super.prepare(rb); + } + + /** + * Overrides the process method to handle CombinedQueryResponseBuilder instances. This method + * processes the responses from multiple shards, combines them using the specified + * QueryAndResponseCombiner strategy, and sets the appropriate results and metadata in the + * CombinedQueryResponseBuilder. + * + * @param rb the ResponseBuilder object to process Review Comment: I wonder if we can abstract the subquery propagated execution in a separate class: ``` public class SubQueryExecutor { private final SolrQueryRequest sharedReq; private final List<SearchComponent> components; public SubQueryExecutor(SolrQueryRequest req, List<SearchComponent> components) { this.sharedReq = req; this.components = components; } public void execute(List<ResponseBuilder> builders) throws IOException { for (ResponseBuilder rb : builders) { for (SearchComponent c : components) { c.prepare(rb); // or distributedPrepare } } for (ResponseBuilder rb : builders) { for (SearchComponent c : components) { c.process(rb); // or distributedProcess } } } } ``` This will avoid nesting like ` super.prepare(rbNew); ` ########## solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java: ########## @@ -0,0 +1,169 @@ +/* + * 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.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.params.CombinerParams; +import org.apache.solr.common.params.CursorMarkParams; +import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.response.BasicResultContext; +import org.apache.solr.response.ResultContext; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.search.DocListAndSet; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.combine.QueryAndResponseCombiner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The CombinedQueryComponent class extends QueryComponent and provides support for executing + * multiple queries and combining their results. + */ +public class CombinedQueryComponent extends QueryComponent { + + public static final String COMPONENT_NAME = "combined_query"; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** + * Overrides the prepare method to handle combined queries. + * + * @param rb the ResponseBuilder to prepare + * @throws IOException if an I/O error occurs during preparation + */ + @Override + public void prepare(ResponseBuilder rb) throws IOException { Review Comment: How does this work with grouping, highlighting and faceting? Those methods from QueryComponent are not overridden here, so updated ResponseBuilders are not propagated there. ########## solr/core/src/java/org/apache/solr/search/combine/ReciprocalRankFusion.java: ########## @@ -0,0 +1,234 @@ +/* + * 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.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; +import org.apache.lucene.document.Document; +import org.apache.lucene.search.Explanation; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TotalHits; +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.common.util.SimpleOrderedMap; +import org.apache.solr.handler.component.ShardDoc; +import org.apache.solr.schema.IndexSchema; +import org.apache.solr.search.DocIterator; +import org.apache.solr.search.DocList; +import org.apache.solr.search.DocSlice; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.SolrIndexSearcher; +import org.apache.solr.search.SortedIntDocSet; + +/** + * The ReciprocalRankFusion class implements a query and response combiner that uses the Reciprocal + * Rank Fusion (RRF) algorithm to combine multiple ranked lists into a single ranked list. + */ +public class ReciprocalRankFusion extends QueryAndResponseCombiner { + + private final int k; + + /** + * Constructs a ReciprocalRankFusion instance. + * + * @param requestParams the SolrParams containing the configuration parameters for this combiner. + */ + public ReciprocalRankFusion(SolrParams requestParams) { + super(requestParams); + this.k = + requestParams.getInt(CombinerParams.COMBINER_RRF_K, CombinerParams.COMBINER_RRF_K_DEFAULT); + } + + @Override + public QueryResult combine(List<QueryResult> rankedLists) { + List<DocList> docLists = new ArrayList<>(rankedLists.size()); + for (QueryResult rankedList : rankedLists) { + docLists.add(rankedList.getDocList()); + } + QueryResult combinedResult = new QueryResult(); + combineResults(combinedResult, docLists, false); + return combinedResult; + } + + @Override + public List<ShardDoc> combine(Map<String, List<ShardDoc>> shardDocMap) { + HashMap<String, Float> docIdToScore = new HashMap<>(); + Map<String, ShardDoc> docIdToShardDoc = new HashMap<>(); + List<ShardDoc> finalShardDocList = new ArrayList<>(); + for (Map.Entry<String, List<ShardDoc>> shardDocEntry : shardDocMap.entrySet()) { + List<ShardDoc> shardDocList = shardDocEntry.getValue(); + int ranking = 1; + while (ranking <= shardDocList.size() && ranking <= upTo) { + String docId = shardDocList.get(ranking - 1).id.toString(); + docIdToShardDoc.put(docId, shardDocList.get(ranking - 1)); + float rrfScore = 1f / (k + ranking); + docIdToScore.compute(docId, (id, score) -> (score == null) ? rrfScore : score + rrfScore); + ranking++; + } + } + // TODO: Add the remaining items out of upTo limit to the docIdToScore + List<Map.Entry<String, Float>> sortedByScoreDescending = + docIdToScore.entrySet().stream() + .sorted(Collections.reverseOrder(Map.Entry.comparingByValue())) + .toList(); + for (Map.Entry<String, Float> scoredDoc : sortedByScoreDescending) { + String docId = scoredDoc.getKey(); + Float score = scoredDoc.getValue(); + ShardDoc shardDoc = docIdToShardDoc.get(docId); + shardDoc.score = score; Review Comment: This is dangerous - this is mutating the original ShardDoc object. It might be referred to by another component, and is a bad idea to modify in place. ########## solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java: ########## @@ -0,0 +1,169 @@ +/* + * 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.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.params.CombinerParams; +import org.apache.solr.common.params.CursorMarkParams; +import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.response.BasicResultContext; +import org.apache.solr.response.ResultContext; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.search.DocListAndSet; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.combine.QueryAndResponseCombiner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The CombinedQueryComponent class extends QueryComponent and provides support for executing + * multiple queries and combining their results. + */ +public class CombinedQueryComponent extends QueryComponent { + + public static final String COMPONENT_NAME = "combined_query"; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** + * Overrides the prepare method to handle combined queries. + * + * @param rb the ResponseBuilder to prepare + * @throws IOException if an I/O error occurs during preparation + */ + @Override + public void prepare(ResponseBuilder rb) throws IOException { + if (rb instanceof CombinedQueryResponseBuilder crb) { + SolrParams params = crb.req.getParams(); + String[] queriesToCombineKeys = params.getParams(CombinerParams.COMBINER_QUERY); + for (String queryKey : queriesToCombineKeys) { + final var unparsedQuery = params.get(queryKey); + ResponseBuilder rbNew = new ResponseBuilder(rb.req, new SolrQueryResponse(), rb.components); + rbNew.setQueryString(unparsedQuery); + super.prepare(rbNew); + crb.responseBuilders.add(rbNew); + } + } + super.prepare(rb); + } + + /** + * Overrides the process method to handle CombinedQueryResponseBuilder instances. This method + * processes the responses from multiple shards, combines them using the specified + * QueryAndResponseCombiner strategy, and sets the appropriate results and metadata in the + * CombinedQueryResponseBuilder. + * + * @param rb the ResponseBuilder object to process + * @throws IOException if an I/O error occurs during processing + */ + @Override + public void process(ResponseBuilder rb) throws IOException { + if (rb instanceof CombinedQueryResponseBuilder crb) { + boolean partialResults = false; + boolean segmentTerminatedEarly = false; + List<QueryResult> queryResults = new ArrayList<>(); + for (ResponseBuilder rbNow : crb.responseBuilders) { + super.process(rbNow); + DocListAndSet docListAndSet = rbNow.getResults(); + QueryResult queryResult = new QueryResult(); + queryResult.setDocListAndSet(docListAndSet); + queryResults.add(queryResult); + partialResults |= SolrQueryResponse.isPartialResults(rbNow.rsp.getResponseHeader()); + rbNow.setCursorMark(rbNow.getCursorMark()); + if (rbNow.rsp.getResponseHeader() != null) { + segmentTerminatedEarly |= + (boolean) + rbNow + .rsp + .getResponseHeader() + .getOrDefault( + SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY, false); + } + } + QueryAndResponseCombiner combinerStrategy = + QueryAndResponseCombiner.getImplementation(rb.req.getParams()); + QueryResult combinedQueryResult = combinerStrategy.combine(queryResults); + combinedQueryResult.setPartialResults(partialResults); + combinedQueryResult.setSegmentTerminatedEarly(segmentTerminatedEarly); + crb.setResult(combinedQueryResult); + ResultContext ctx = new BasicResultContext(crb); + crb.rsp.addResponse(ctx); + crb.rsp + .getToLog() + .add( + "hits", + crb.getResults() == null || crb.getResults().docList == null + ? 0 + : crb.getResults().docList.matches()); + if (!crb.req.getParams().getBool(ShardParams.IS_SHARD, false)) { + if (null != crb.getNextCursorMark()) { + crb.rsp.add( + CursorMarkParams.CURSOR_MARK_NEXT, crb.getNextCursorMark().getSerializedTotem()); + } + } + + if (crb.mergeFieldHandler != null) { + crb.mergeFieldHandler.handleMergeFields(crb, crb.req.getSearcher()); + } else { + doFieldSortValues(rb, crb.req.getSearcher()); + } + doPrefetch(crb); + } else { + super.process(rb); + } + } + + @Override + protected Map<Object, ShardDoc> createShardResult( + ResponseBuilder rb, + int resultSize, + ShardFieldSortedHitQueue queue, + Map<String, List<ShardDoc>> shardDocMap, + SolrDocumentList responseDocs) { + QueryAndResponseCombiner combinerStrategy = + QueryAndResponseCombiner.getImplementation(rb.req.getParams()); + List<ShardDoc> combinedShardDocs = combinerStrategy.combine(shardDocMap); + Map<String, ShardDoc> shardDocIdMap = new HashMap<>(); + shardDocMap.forEach( + (shardKey, shardDocs) -> + shardDocs.forEach(shardDoc -> shardDocIdMap.put(shardDoc.id.toString(), shardDoc))); + Map<Object, ShardDoc> resultIds = new HashMap<>(); + float maxScore = 0.0f; + for (int i = 0; i < resultSize; i++) { + ShardDoc shardDoc = combinedShardDocs.get(i); + shardDoc.positionInResponse = i; + maxScore = Math.max(maxScore, shardDoc.score); Review Comment: How does this normalise across different query types (KNN, BM25,, filters)? ########## solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java: ########## @@ -0,0 +1,169 @@ +/* + * 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.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.params.CombinerParams; +import org.apache.solr.common.params.CursorMarkParams; +import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.response.BasicResultContext; +import org.apache.solr.response.ResultContext; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.search.DocListAndSet; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.combine.QueryAndResponseCombiner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The CombinedQueryComponent class extends QueryComponent and provides support for executing + * multiple queries and combining their results. + */ +public class CombinedQueryComponent extends QueryComponent { Review Comment: QueryComponent is specifically designed for Solr's distributed search processing. We override prepare method, but then invoke super.prepare with the sub response. This could quickly get uncontrolled for a query with large number of clauses. I would suggest overriding SearchComponent and defining explicit subBuilder.process and subBuilder.prepare methods. -- 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]
