Makes an empty index with the caller's tokenizer and, unless given, k1 1.2 and b 0.75.
Protected recomputeSearches. With no options it answers exactly what BM25Index has always answered.
The query text, read with the index's tokenizer.
The most results answered.
match and prefix; see LexicalSearchOptions.
The matching documents, highest score first.
10
The index as plain JSON.
Protected restoreFills this index from a saved one, or throws an Error naming what keeps it from being one toJSON writes.
Static fromJSONA saved index restored, with the tokenizer it was made with.
When the saved index is of another version or is not one LexicalIndex.toJSON could have written; the message names what is wrong.
Protected k1Term saturation parameter (typical range: 1.2-2.0).
Protected bDocument length normalization (0 = none, 1 = full).
Protected documentsMap of document ID to internal document representation.
Protected invertedEach term's documents with the term's count in each: term -> { docId -> termFrequency }.
Protected idfEach term's IDF, recomputed after documents are added or removed.
Protected avgAverage document length across the index (in tokens).
Protected idfWhether the IDF cache needs recomputation.
Protected Readonly tokenizeThe tokenizer this index was made with.
The BM25 engine over a caller's tokenizer. It imports nothing, so a page can load it; it ranks documents holding any query word (or only those holding every one), matches a stored word whole or by a query word it begins with, and is saved with LexicalIndex.toJSON and restored with LexicalIndex.fromJSON.
A document's score is the sum, over the query's words, of
IDF(t) * (tf(t,D) * (k1 + 1)) / (tf(t,D) + k1 * (1 - b + b * |D| / avgdl)), with the Robertson-WalkerIDF(t) = log((N - n(t) + 0.5) / (n(t) + 0.5) + 1).Example