Rowles.LeanCorpus.Search.Scoring
Classes
Bm25LSimilarity
BM25L scoring model. Extends BM25 with a delta that is modulated by tf/(1+tf), providing a more nuanced lower-bound correction than the constant delta in BM25+.
Score = idf * (normalised_tf + delta * tf / (1 + tf)).
Default: k1=1.2, b=0.75, delta=0.5.
Bm25PlusSimilarity
BM25+ scoring model. Extends BM25 with a lower-bound delta constant to fix BM25's tendency to produce near-zero scores for very short documents.
Score = idf * (normalised_tf + delta).
Default: k1=1.2, b=0.75, delta=1.0.
Bm25Scorer
BM25 scorer. Computes relevance scores for term matches.
Bm25Similarity
BM25 scoring (default). Delegates to Bm25Scorer.
CollapseField
Configuration for result collapsing (field grouping). Keeps only the best document per unique value of the collapse field.
DirichletSimilarity
Language-model similarity with Dirichlet (Bayesian) smoothing. Smooths the document model towards the collection model using a prior parameter 渭.
Score = log((tf + 渭 路 P(t|C)) / (|d| + 渭)), where P(t|C) = collectionFrequency / totalTermsInCollection.
Default 渭 = 2000 (optimised for short to medium-length documents).
DoubleValuesSource
Produces a double value for a document, optionally using its query score.
Explanation
A breakdown of how a document's score was computed, useful for debugging relevance tuning and understanding BM25 behaviour.
FacetResult
The facet result for one field: the field name and its value-count buckets.
FacetsCollector
Collects per-field value counts across a result set for faceted navigation.
IndexStats
Immutable corpus-wide statistics computed once at IndexSearcher construction. Shared across all segment readers so BM25 scores are comparable across segment boundaries.
LMAbsoluteDiscountingSimilarity
Language-model similarity with absolute discounting smoothing. Subtracts a constant 未 from each observed term count and redistributes the probability mass to unseen terms via the collection model.
Score = log((max(tf - 未, 0) + 未 路 |d| 路 P(t|C)) / |d|), where P(t|C) = collectionFrequency / totalTermsInCollection.
Default 未 = 0.7.
LMJelinekMercerSimilarity
Language-model similarity with Jelinek-Mercer (linear interpolation) smoothing. Interpolates the document model with the collection model using a coefficient 位.
Score = log((1-位) 路 (tf/|d|) + 位 路 P(t|C)), where P(t|C) = collectionFrequency / totalTermsInCollection.
Default 位 = 0.1.
OrdinalMap
Maps sorted local ordinals from several readers into one stable, lexicographically ordered ordinal space.
QueryRescorer
Reranks a first-pass result set with scores from a second query.
Scorer
Scores candidate documents produced by a custom query weight.
SortField
Specifies a field and direction for sorting search results.
SortRescorer
Reranks a first-pass result set using one or more sort fields.
TfIdfAugmentedSimilarity
Augmented TF-IDF scoring model. Uses a pivoted term frequency that reduces the impact of high-TF terms within a document. The parameter K controls the pivot point.
tf_aug = K + (1-K) * tf / (tf + K).
len_norm = 1 / sqrt(dl).
Score = tf_aug * idf * len_norm.
Default: K=0.5.
TfIdfDoubleNormSimilarity
Double-normalised TF-IDF scoring model. Combines augmented/pivoted term frequency (reducing the impact of high-TF terms) with pivoted document length normalisation (less aggressive penalty for long documents).
tf_norm = K + (1-K) * tf / (tf + K).
len_norm = 1 / ((1-s) + s * dl/avgdl).
Score = tf_norm * idf * len_norm.
Default: K=0.5, s=0.2.
TfIdfPivotedSimilarity
Pivoted document length normalisation TF-IDF scoring model (Singhal et al.). Uses a linear interpolation between constant and dl/avgdl instead of 1/sqrt(dl), which penalises long documents less aggressively.
tf = sqrt(tf).
len_norm = 1 / ((1-s) + s * dl/avgdl).
Score = tf * idf * len_norm.
Default: s=0.2.
TfIdfSimilarity
Classic TF-IDF scoring model.
TopDocs
Encapsulates the results of a search query.
TopNCollectorWrapper
Wraps a TopNCollector struct as an ICollector for use in extensible search pipelines.
Weight
Defines a custom scoring pipeline over candidates from an executable approximation query.
Structs
CountCollector
A simple count-only collector that tracks hit count without storing results. Useful for count queries where actual documents are not needed.
FacetBucket
A single facet bucket: a field value and how many matching documents have it.
ScoreDoc
Represents a scored document in search results.
TopNCollector
Bounded min-heap collector that keeps the top-N highest-scoring documents. Single allocation: the ScoreDoc[topN] backing array.
Interfaces
ICollector
Abstraction for collecting search results. Implementations can count, aggregate, or collect in custom ways beyond the default TopN scoring.
ILeafCollector
Optional collector extension that receives segment boundaries and the current scorer.
ISimilarity
Pluggable scoring model. Supports both classic similarities (BM25, TF-IDF) and language-model similarities (Dirichlet, Jelinek-Mercer, Absolute Discounting).
Enums
CollapseMode
How to select the representative document per group.
SortFieldType
Specifies the data type and sort behaviour for a field-based sort criterion.
SortValueSelector
Selects a value from a multi-valued sort field.