Class TopScoreDocCollector

  • All Implemented Interfaces:

    public abstract class TopScoreDocCollector
    extends TopDocsCollector<ScoreDoc>
    A Collector implementation that collects the top-scoring hits, returning them as a TopDocs. This is used by IndexSearcher to implement TopDocs-based search. Hits are sorted by score descending and then (when the scores are tied) docID ascending. When you create an instance of this collector you should know in advance whether documents are going to be collected in doc Id order or not.

    NOTE: The values Float.NaN and Float.NEGATIVE_INFINITY are not valid scores. This collector will not properly collect hits with such scores.

    • Method Detail

      • newTopDocs

        protected TopDocs newTopDocs​(ScoreDoc[] results,
                                     int start)
        Description copied from class: TopDocsCollector
        Returns a TopDocs instance containing the given results. If results is null it means there are no results to return, either because there were 0 calls to collect() or because the arguments to topDocs were invalid.
        newTopDocs in class TopDocsCollector<ScoreDoc>
      • needsScores

        public boolean needsScores()
        Description copied from interface: Collector
        Indicates if document scores are needed by this collector.
        true if scores are needed.