cpoerschke commented on code in PR #2489: URL: https://github.com/apache/solr/pull/2489#discussion_r1688453058
########## solr/core/src/java/org/apache/solr/search/combining/CombineQParserPlugin.java: ########## @@ -0,0 +1,167 @@ +/* + * 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.combining; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.lucene.search.BooleanClause.Occur; +import org.apache.lucene.search.MatchNoDocsQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.QueryVisitor; +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.QueryComponent; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.search.ExtendedQueryBase; +import org.apache.solr.search.QParser; +import org.apache.solr.search.QParserPlugin; +import org.apache.solr.search.QueryCommand; +import org.apache.solr.search.QueryParsing; +import org.apache.solr.search.QueryResult; +import org.apache.solr.search.SolrIndexSearcher; +import org.apache.solr.search.SyntaxError; + +public class CombineQParserPlugin extends QParserPlugin { + public static final String NAME = "combine"; + + @Override + public QParser createParser( + String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { + return new CombineQParser(qstr, localParams, params, req); + } + + static class CombineQParser extends QParser { + + private List<String> unparsedQueries; + private QueriesCombiner queriesCombiningStrategy; + private List<QParser> queryParsers; + private List<Query> queries; + + public CombineQParser( + String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { + super(qstr, localParams, params, req); + } + + @Override + public Query parse() throws SyntaxError { + + var queriesToCombineKeys = localParams.getParams("keys"); + if (queriesToCombineKeys == null) { + queriesToCombineKeys = params.getParams(CombinerParams.COMBINER_KEYS); + } + + unparsedQueries = new ArrayList<>(queriesToCombineKeys.length); + queryParsers = new ArrayList<>(queriesToCombineKeys.length); + queries = new ArrayList<>(queriesToCombineKeys.length); + + // nocommit blend localParams and params without needless suffix in local + var blendParams = SolrParams.wrapDefaults(localParams, params); + queriesCombiningStrategy = QueriesCombiner.getImplementation(blendParams); + + String defType = blendParams.get(QueryParsing.DEFTYPE, DEFAULT_QTYPE); Review Comment: Maybe could support different `defType` for different keys, though bit of a niche thing that perhaps. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org