SOLR-5973: Pluggable Ranking Collectors and Merge Strategies

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1597921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joel Bernstein 2014-05-28 03:02:13 +00:00
parent e9906a334b
commit b6d96d1ca8
2 changed files with 16 additions and 3 deletions

View File

@ -153,14 +153,13 @@ public class QueryComponent extends SearchComponent
rb.setQuery( q );
String rankQueryString = rb.req.getParams().get(CommonParams.RQ);
if(rankQueryString != null) {
QParser rqparser = QParser.getParser(rankQueryString, defType, req);
Query rq = rqparser.getQuery();
if(rq instanceof RankQuery) {
RankQuery rankQuery = (RankQuery)rq;
rb.setQuery(rankQuery.wrap(q)); //Wrap the RankQuery around the main query.
rb.setRankQuery(rankQuery);
MergeStrategy mergeStrategy = rankQuery.getMergeStrategy();
if(mergeStrategy != null) {
rb.addMergeStrategy(mergeStrategy);

View File

@ -34,6 +34,7 @@ import org.apache.solr.search.DocListAndSet;
import org.apache.solr.search.QParser;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.SortSpec;
import org.apache.solr.search.RankQuery;
import org.apache.solr.search.grouping.GroupingSpecification;
import org.apache.solr.search.grouping.distributed.command.QueryCommandResult;
@ -77,6 +78,7 @@ public class ResponseBuilder
private CursorMark nextCursorMark;
private List<MergeStrategy> mergeStrategies;
private RankQuery rankQuery;
private DocListAndSet results = null;
@ -248,6 +250,10 @@ public class ResponseBuilder
return this.mergeStrategies;
}
public void setRankQuery(RankQuery rankQuery) {
this.rankQuery = rankQuery;
}
public void setResponseDocs(SolrDocumentList _responseDocs) {
this._responseDocs = _responseDocs;
}
@ -410,7 +416,7 @@ public class ResponseBuilder
*/
public SolrIndexSearcher.QueryCommand getQueryCommand() {
SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
cmd.setQuery(getQuery())
cmd.setQuery(wrap(getQuery()))
.setFilterList(getFilters())
.setSort(getSortSpec().getSort())
.setOffset(getSortSpec().getOffset())
@ -421,6 +427,14 @@ public class ResponseBuilder
return cmd;
}
private Query wrap(Query q) {
if(this.rankQuery != null) {
return this.rankQuery.wrap(q);
} else {
return q;
}
}
/**
* Sets results from a SolrIndexSearcher.QueryResult.
*/