You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "Stephen Woods (Jira)" <ji...@apache.org> on 2024/06/07 02:47:00 UTC
[jira] [Created] (SOLR-17322) Make RankQuery.getTopDocsCollector use covariant generic types
Stephen Woods created SOLR-17322:
------------------------------------
Summary: Make RankQuery.getTopDocsCollector use covariant generic types
Key: SOLR-17322
URL: https://issues.apache.org/jira/browse/SOLR-17322
Project: Solr
Issue Type: Bug
Security Level: Public (Default Security Level. Issues are Public)
Components: search
Affects Versions: 9.6.1, 9.6, 9.4.1, 9.5, 9.4, 9.2.1, 9.3, 9.1.1, 9.2, 9.1, 9.0
Reporter: Stephen Woods
Currently, rank queries can only use TopDocsCollectors that operate on ScoreDocs.
TopDocsCollector has a class signature of:
{code:java}
public abstract class TopDocsCollector<T extends ScoreDoc> implements Collector {code}
It contains a single covariant generic type T, which allows the collection of not only ScoreDocs, but subclasses of ScoreDocs as well (in the event additional information needs to be collected per document during the collection process).
SOLR-15385 involved a large commit that removed raw types from much of the Solr code base. As part of that work, RankQuery was modified so that the getTopDocsCollector method no longer returns a raw TopDocsCollector but instead returns a TopDocsCollector of invariant ScoreDocs. Unfortunately, by doing so, it is no longer possible to use custom TopDocsCollectors that operate on types that extend ScoreDoc in rank queries; they _only_ work with ScoreDocs.
The fix for this issue is very simple: Modify the method signature from:
{code:java}
public abstract TopDocsCollector<ScoreDoc> getTopDocsCollector(
int len, QueryCommand cmd, IndexSearcher searcher) throws IOException; {code}
to
{code:java}
public abstract TopDocsCollector<? extends ScoreDoc> getTopDocsCollector(
int len, QueryCommand cmd, IndexSearcher searcher) throws IOException; {code}
The call site for this method, within SolrIndexSearcher.buildTopDocsCollector, already uses this type signature.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org