Skip to content

BM25Document

Pure TypeScript BM25 (Okapi BM25) inverted index for keyword search.

Zero external dependencies. Suitable for all runtimes including Cloudflare Workers. Designed for moderate corpus sizes (up to ~100K documents) where an in-process index is viable.

BM25 parameters default to the standard values from Robertson & Zaragoza (2009): k1 = 1.2, b = 0.75.

id: string;

Unique identifier for this document.


text: string;

The text content to index.