Section navigation

Public namespace Rowles.LeanCorpus.Search.Scoring

Classes

Public class 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.

Public class 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.

Public class Bm25Scorer

BM25 scorer. Computes relevance scores for term matches.

Public class Bm25Similarity

BM25 scoring (default). Delegates to Bm25Scorer.

Public class CollapseField

Configuration for result collapsing (field grouping). Keeps only the best document per unique value of the collapse field.

Public class 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).

Public class DoubleValuesSource

Produces a double value for a document, optionally using its query score.

Public class Explanation

A breakdown of how a document's score was computed, useful for debugging relevance tuning and understanding BM25 behaviour.

Public class FacetResult

The facet result for one field: the field name and its value-count buckets.

Public class FacetsCollector

Collects per-field value counts across a result set for faceted navigation.

Public class IndexStats

Immutable corpus-wide statistics computed once at IndexSearcher construction. Shared across all segment readers so BM25 scores are comparable across segment boundaries.

Public class 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.

Public class 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.

Public class OrdinalMap

Maps sorted local ordinals from several readers into one stable, lexicographically ordered ordinal space.

Public class QueryRescorer

Reranks a first-pass result set with scores from a second query.

Public class Scorer

Scores candidate documents produced by a custom query weight.

Public class SortField

Specifies a field and direction for sorting search results.

Public class SortRescorer

Reranks a first-pass result set using one or more sort fields.

Public class 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.

Public class 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.

Public class 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.

Public class TfIdfSimilarity

Classic TF-IDF scoring model.

Public class TopDocs

Encapsulates the results of a search query.

Public class TopNCollectorWrapper

Wraps a TopNCollector struct as an ICollector for use in extensible search pipelines.

Public class Weight

Defines a custom scoring pipeline over candidates from an executable approximation query.

Structs

Public struct CountCollector

A simple count-only collector that tracks hit count without storing results. Useful for count queries where actual documents are not needed.

Public struct FacetBucket

A single facet bucket: a field value and how many matching documents have it.

Public struct ScoreDoc

Represents a scored document in search results.

Public struct TopNCollector

Bounded min-heap collector that keeps the top-N highest-scoring documents. Single allocation: the ScoreDoc[topN] backing array.

Interfaces

Public interface ICollector

Abstraction for collecting search results. Implementations can count, aggregate, or collect in custom ways beyond the default TopN scoring.

Public interface ILeafCollector

Optional collector extension that receives segment boundaries and the current scorer.

Public interface ISimilarity

Pluggable scoring model. Supports both classic similarities (BM25, TF-IDF) and language-model similarities (Dirichlet, Jelinek-Mercer, Absolute Discounting).

Enums

Public enum CollapseMode

How to select the representative document per group.

Public enum SortFieldType

Specifies the data type and sort behaviour for a field-based sort criterion.

Public enum SortValueSelector

Selects a value from a multi-valued sort field.