SimilarityBase

abstract class SimilarityBase : Similarity

A subclass of Similarity that provides a simplified API for its descendants. Subclasses are only required to implement the .score and .toString methods. Implementing .explain is optional, inasmuch as SimilarityBase already provides a basic explanation of the score and the term frequency. However, implementers of a subclass are encouraged to include as much detail about the scoring method as possible.

Note: multi-word queries such as phrase queries are scored in a different way than Lucene's default ranking algorithm: whereas it "fakes" an IDF value for the phrase as a whole (since it does not know it), this class instead scores phrases as a summation of the individual term scores.

Inheritors

Constructors

Link copied to clipboard
constructor()

Default constructor: parameter-free

constructor(discountOverlaps: Boolean)

Primary constructor.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

True if overlap tokens (tokens with a position of increment of zero) are discounted from the document's length.

Functions

Link copied to clipboard

Computes the normalization value for a field at index-time.

Link copied to clipboard
open override fun scorer(boost: Float, collectionStats: CollectionStatistics, vararg termStats: TermStatistics): Similarity.SimScorer

Compute any collection-level weight (e.g. IDF, average document length, etc) needed for scoring a query.

Link copied to clipboard
abstract override fun toString(): String

Subclasses must override this method to return the name of the Similarity and preferably the values of parameters (if any) as well.