Package org.apache.lucene.search.similarities

# Class Similarity.SimScorer

java.lang.Object
org.apache.lucene.search.similarities.Similarity.SimScorer

Enclosing class:
  `Similarity`

public abstract static class Similarity.SimScorer extends Object
Stores the weight for a query across the indexed collection. This abstract implementation is empty; descendants of `Similarity` should subclass `SimWeight` and define the statistics they require in the subclass. Examples include idf, average field length, etc.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SimScorer()`
Sole constructor.

## Method Summary

Modifier and Type
Method
Description
`Explanation`
`explain(Explanation freq, long norm)`
Explain the score for a single document
`abstract float`
`score(float freq, long norm)`
Score a single document.

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

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

## Constructor Details

### SimScorer

protected SimScorer()
Sole constructor. (For invocation by subclass constructors.)

## Method Details

### score

public abstract float score(float freq, long norm)
Score a single document. `freq` is the document-term sloppy frequency and must be finite and positive. `norm` is the encoded normalization factor as computed by `Similarity.computeNorm(FieldInvertState)` at index time, or `1` if norms are disabled. `norm` is never `0`.

Score must not decrease when `freq` increases, ie. if `freq1 > freq2`, then `score(freq1, norm) >= score(freq2, norm)` for any value of `norm` that may be produced by `Similarity.computeNorm(FieldInvertState)`.

Score must not increase when the unsigned `norm` increases, ie. if `Long.compareUnsigned(norm1, norm2) > 0` then `score(freq, norm1) <= score(freq, norm2)` for any legal `freq`.

As a consequence, the maximum score that this scorer can produce is bound by `score(Float.MAX_VALUE, 1)`.

Parameters:
  `freq` - sloppy term frequency, must be finite and positive
  `norm` - encoded normalization factor or `1` if norms are disabled
Returns:
  document's score

### explain

public Explanation explain(Explanation freq, long norm)
Explain the score for a single document

Parameters:
  `freq` - Explanation of how the sloppy term frequency was computed
  `norm` - encoded normalization factor, as returned by `Similarity.computeNorm(org.apache.lucene.index.FieldInvertState)`, or `1` if norms are disabled
Returns:
  document's score