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.
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”records
Section titled “records”Iterable<R>
termsOf
Section titled “termsOf”(record, id) => readonly string[]
Returns
Section titled “Returns”Throws
Section titled “Throws”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.