Skip to content

termIndex<R>(records, termsOf): TermIndex

Defined in: packages/term-index/src/term-index.ts:205

Build a read-only counted index from caller-tokenized documents. The selector runs once per input record. The index retains terms, counts, and document positions. It can discard the source records after construction.

Expected O(n + t) build time for n documents and t token occurrences, plus the selector’s work. Build workspace and retained storage are O(n + v + p) for v vocabulary terms and p distinct postings.

R

Iterable<R>

(record, id) => readonly string[]

TermIndex

With INVALID_TERMS for a selector result other than an array of strings or MAX_CAPACITY_EXCEEDED when corpus counts or packed storage exceed their bounds. Errors thrown by the input iterable and selector propagate.