Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-17322

Once again allow rank queries to use custom TopDocsCollectors that operate on types that extend ScoreDocs (covariant generic types)

    XMLWordPrintableJSON

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
    • 9.7
    • search

    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

          Activity

            People

              cpoerschke Christine Poerschke
              stephen-woods Stephen Woods
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 10m
                  3h 10m