Record Class CollectionStatistics

java.lang.Object
java.lang.Record
org.apache.lucene.search.CollectionStatistics
Record Components:
field - Field's name.

This value is never null.

maxDoc - The total number of documents in the range [1 .. Long.MAX_VALUE], regardless of whether they all contain values for this field.

This value is always a positive number. @see IndexReader#maxDoc()

docCount - The total number of documents that have at least one term for this field , in the range [1 .. maxDoc()].

This value is always a positive number, and never exceeds maxDoc(). @see Terms#getDocCount()

sumTotalTermFreq - The total number of tokens for this field , in the range [sumDocFreq() .. Long.MAX_VALUE]. This is the "word count" for this field across all documents. It is the sum of TermStatistics.totalTermFreq() across all terms. It is also the sum of each document's field length across all documents.

This value is always a positive number, and always at least sumDocFreq(). @see Terms#getSumTotalTermFreq()

sumDocFreq - The total number of posting list entries for this field, in the range [docCount() .. sumTotalTermFreq()]. This is the sum of term-document pairs: the sum of TermStatistics.docFreq() across all terms. It is also the sum of each document's unique term count for this field across all documents.

This value is always a positive number, always at least docCount(), and never exceeds sumTotalTermFreq(). @see Terms#getSumDocFreq()


public record CollectionStatistics(String field, long maxDoc, long docCount, long sumTotalTermFreq, long sumDocFreq) extends Record
Contains statistics for a collection (field).

This class holds statistics across all documents for scoring purposes:

The following conditions are always true:

  • All statistics are positive integers: never zero or negative.
  • docCount <= maxDoc
  • docCount <= sumDocFreq <= sumTotalTermFreq

Values may include statistics on deleted documents that have not yet been merged away.

Be careful when performing calculations on these values because they are represented as 64-bit integer values, you may need to cast to double for your use.

WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Constructor Details

  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • field

      public String field()
      Returns the value of the field record component.
      Returns:
      the value of the field record component
    • maxDoc

      public long maxDoc()
      Returns the value of the maxDoc record component.
      Returns:
      the value of the maxDoc record component
    • docCount

      public long docCount()
      Returns the value of the docCount record component.
      Returns:
      the value of the docCount record component
    • sumTotalTermFreq

      public long sumTotalTermFreq()
      Returns the value of the sumTotalTermFreq record component.
      Returns:
      the value of the sumTotalTermFreq record component
    • sumDocFreq

      public long sumDocFreq()
      Returns the value of the sumDocFreq record component.
      Returns:
      the value of the sumDocFreq record component