Defined in: packages/term-index/src/term-index.ts:24
A read-only counted inverted index. Document IDs are zero-based input positions.
Properties
Section titled “Properties”
readonlysize:number
Defined in: packages/term-index/src/term-index.ts:26
Number of distinct terms.
documentCount
Section titled “documentCount”
readonlydocumentCount:number
Defined in: packages/term-index/src/term-index.ts:28
Number of documents, including those with no terms.
tokenCount
Section titled “tokenCount”
readonlytokenCount:number
Defined in: packages/term-index/src/term-index.ts:30
Total token occurrences, including repeats.
averageDocumentLength
Section titled “averageDocumentLength”
readonlyaverageDocumentLength:number
Defined in: packages/term-index/src/term-index.ts:32
Tokens per document, or zero if there are no documents.
readonlykeys: () =>IterableIterator<string>
Defined in: packages/term-index/src/term-index.ts:34
Iterate distinct terms in first-seen order.
Returns
Section titled “Returns”IterableIterator<string>
documentLength
Section titled “documentLength”
readonlydocumentLength: (id) =>number|undefined
Defined in: packages/term-index/src/term-index.ts:36
Number of tokens in a document. Returns undefined for an absent ID. O(1).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number | undefined
documentFrequency
Section titled “documentFrequency”
readonlydocumentFrequency: (term) =>number
Defined in: packages/term-index/src/term-index.ts:38
Number of documents containing the term. Returns zero for an absent term. Expected O(1).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number
postings
Section titled “postings”
readonlypostings: (term) =>IterableIterator<TermPosting>
Defined in: packages/term-index/src/term-index.ts:40
Iterate the term’s counted postings in ascending document ID order.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”IterableIterator<TermPosting>
search
Section titled “search”
readonlysearch: (terms,options?) => readonlyTermHit[]
Defined in: packages/term-index/src/term-index.ts:47
Rank documents matching any supplied exact term. Ties in score favor lower IDs. Repeated query terms contribute once. The returned array and hits are independent of the index.
Parameters
Section titled “Parameters”readonly string[]
options?
Section titled “options?”Returns
Section titled “Returns”readonly TermHit[]
Throws
Section titled “Throws”With INVALID_LIMIT for a limit outside the nonnegative safe integers
or INVALID_TERMS for an argument other than an array of strings. Eligibility accessor errors propagate.