ScoreDoc (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.search, class: ScoreDoc

Package org.apache.lucene.search

# Class ScoreDoc

java.lang.Object
org.apache.lucene.search.ScoreDoc

Direct Known Subclasses:
  `FieldDoc`, `FieldValueHitQueue.Entry`

public class ScoreDoc extends Object
Holds one hit in `TopDocs`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Comparator<ScoreDoc>`
  `COMPARATOR`
  Utility comparator that sorts by score descending, then by docId ascending
  `int`
  `doc`
  A hit document's number.
  `float`
  `score`
  The score of this document for the query.
  `int`
  `shardIndex`
  Only set by `TopDocs.merge(int, org.apache.lucene.search.TopDocs[])`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScoreDoc(int doc, float score)`
  Constructs a ScoreDoc.
  `ScoreDoc(int doc, float score, int shardIndex)`
  Constructs a ScoreDoc.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### score

    public float score
    The score of this document for the query.

  - ### doc

    public int doc
    A hit document's number.
    See Also:
      - `StoredFields.document(int)`

  - ### shardIndex

    public int shardIndex
    Only set by `TopDocs.merge(int, org.apache.lucene.search.TopDocs[])`

  - ### COMPARATOR

    public static final Comparator<ScoreDoc> COMPARATOR
    Utility comparator that sorts by score descending, then by docId ascending

- ## Constructor Details

  - ### ScoreDoc

    public ScoreDoc(int doc, float score)
    Constructs a ScoreDoc.

  - ### ScoreDoc

    public ScoreDoc(int doc, float score, int shardIndex)
    Constructs a ScoreDoc.

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`