Table of Contents

Public classSealed SpellIndex

Namespace
Rowles.LeanLucene.Search.Suggestions
Assembly
Rowles.LeanLucene.dll

Pre-built character-trigram inverted index for fast spelling correction. Build once via Build(IndexSearcher, string), then call Suggest(string, int, int) per query. This mirrors Lucene.NET's SpellChecker pattern: amortise the dictionary scan at build time, achieve near-constant-time lookups at query time.

public sealed class SpellIndex
SpellIndex

Public property TermCount

The number of unique terms in this index.

Public method Build(IndexSearcher, string)

Builds a SpellIndex for the given field by extracting all unique terms from the segment readers and constructing a trigram inverted index. This is an O(T * L) operation where T is the unique term count and L is average term length. Call once and reuse for multiple Suggest(string, int, int) calls.

Internal methodInternal BuildFromTerms(IEnumerable<(string Term, int DocFreq)>)

Builds a SpellIndex for the given field from pre-collected term/docFreq pairs. Useful for testing without an IndexSearcher.

Public method Suggest(string, int, int)

Suggests corrections for the given query term. The overlap counts array is rented from System.Buffers.ArrayPool`1 so repeated calls allocate only the small result list.