Class TermStatistics

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

public class TermStatistics extends Object
Contains statistics for a specific term

This class holds statistics for this term across all documents for scoring purposes:

  • docFreq: number of documents this term occurs in.
  • totalTermFreq: number of tokens for this term.

The following conditions are always true:

  • All statistics are positive integers: never zero or negative.
  • docFreq <= totalTermFreq
  • docFreq <= sumDocFreq of the collection
  • totalTermFreq <= sumTotalTermFreq of the collection

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

    • TermStatistics

      public TermStatistics(BytesRef term, long docFreq, long totalTermFreq)
      Creates statistics instance for a term.
      Parameters:
      term - Term bytes
      docFreq - number of documents containing the term in the collection.
      totalTermFreq - number of occurrences of the term in the collection.
      Throws:
      NullPointerException - if term is null.
      IllegalArgumentException - if docFreq is negative or zero.
      IllegalArgumentException - if totalTermFreq is less than docFreq.
  • Method Details