Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
9.0, 9.1, 9.2, 9.1.1, 9.3, 9.2.1, 9.4, 9.5, 9.4.1, 9.6, 9.6.1
Description
Make RankQuery.getTopDocsCollector use covariant generic types
Currently, rank queries can only use TopDocsCollectors that operate on ScoreDocs.
TopDocsCollector has a class signature of:
public abstract class TopDocsCollector<T extends ScoreDoc> implements Collector
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. Any attempt to use a class other than ScoreDoc will result in a compilation error.
The fix for this issue is very simple: Modify the method signature from:
public abstract TopDocsCollector<ScoreDoc> getTopDocsCollector( int len, QueryCommand cmd, IndexSearcher searcher) throws IOException;
to
public abstract TopDocsCollector<? extends ScoreDoc> getTopDocsCollector( int len, QueryCommand cmd, IndexSearcher searcher) throws IOException;
The call site for this method, within SolrIndexSearcher.buildTopDocsCollector, already uses this type signature.
Attachments
Issue Links
- is caused by
-
SOLR-15385 Address rawtypes warnings
- Closed
- links to