Class TopDocs

java.lang.Object
org.apache.lucene.search.TopDocs
Direct Known Subclasses:
TopFieldDocs

public class TopDocs extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The top hits for the query.
    int
    The total number of hits for the query.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TopDocs(int totalHits, ScoreDoc[] scoreDocs, float maxScore)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the maximum score value encountered.
    static TopDocs
    merge(Sort sort, int topN, TopDocs[] shardHits)
    Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by the specified Sort.
    void
    setMaxScore(float maxScore)
    Sets the maximum score value encountered.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • totalHits

      public int totalHits
      The total number of hits for the query.
    • scoreDocs

      public ScoreDoc[] scoreDocs
      The top hits for the query.
  • Constructor Details

    • TopDocs

      public TopDocs(int totalHits, ScoreDoc[] scoreDocs, float maxScore)
  • Method Details

    • getMaxScore

      public float getMaxScore()
      Returns the maximum score value encountered. Note that in case scores are not tracked, this returns Float.NaN.
    • setMaxScore

      public void setMaxScore(float maxScore)
      Sets the maximum score value encountered.
    • merge

      public static TopDocs merge(Sort sort, int topN, TopDocs[] shardHits) throws IOException
      Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by the specified Sort. Each of the TopDocs must have been sorted by the same Sort, and sort field values must have been filled (ie, fillFields=true must be passed to TopFieldCollector.create(org.apache.lucene.search.Sort, int, boolean, boolean, boolean, boolean).

      Pass sort=null to merge sort by score descending.

      Throws:
      IOException