Querylight TS Demo

TF-IDF and BM25 Ranking

Choose between classic term weighting and Lucene-style BM25 scoring.

Back to docs search

Reference Entry

TF-IDF and BM25 Ranking

Ranking · foundation · order 10

Choose between classic term weighting and Lucene-style BM25 scoring.

TF-IDF and BM25 Ranking

TextFieldIndex supports two ranking algorithms.

BM25

  • Better default for mixed-length content
  • Common search-engine ranking baseline
  • Configurable with k1 and b

TF-IDF

  • Simple and familiar
  • Useful for debugging or comparison
import { RankingAlgorithm, TextFieldIndex } from "@tryformation/querylight-ts";

const bm25 = new TextFieldIndex(undefined, undefined, RankingAlgorithm.BM25);
const tfidf = new TextFieldIndex(undefined, undefined, RankingAlgorithm.TFIDF);

The docs browser keeps both indexes live and lets you switch between them from the toolbar.

Learn more