Rust · inverted index · TF-IDF

Search that shows
its own work.

Trailhead is a full-text search engine in Rust, built from scratch and small enough to read end to end. Tokenizer, inverted index, TF-IDF ranking, no black box. Here is the real thing, running in your browser.

  1. Type something above.

tokenized, indexed, and ranked entirely in this page

What it does

Four pieces turn a folder of text files into ranked search results.

Tokenizer

Lowercases text, splits on non-alphanumeric characters, and optionally filters a small stopword list.

Inverted index

Maps each term to the documents it appears in, with per-document term counts, so lookups skip everything that does not match.

TF-IDF ranking

Scores documents by term frequency times inverse document frequency, so rare and repeated terms carry more weight.

Simple CLI

Two commands, index a directory of text files, then search it with a ranked top-N list of results.

Index it. Search it.

The index is saved as plain JSON so you can open it and see exactly what got indexed.

trailhead index ./my-notes
trailhead search "inverted index ranking" --top 5