← All work

Sift

Local-first full-text search over personal notes, built on SQLite FTS5 with an incremental indexer and a WASM build.

Year
2025
Role
Design, implementation
Status
Shipped
Stack
  • Rust
  • SQLite
  • WASM
Links
Source

Sift turns a folder of Markdown notes into a fast, private search index. Everything runs on your machine. The index is a single SQLite file you can copy, back up, or delete.

Constraints

Personal search is a different problem from web search. Corpora are small — tens of thousands of documents — but latency expectations are high, and the data is sensitive. A local index is both the fastest and the most private option.

Sift therefore avoids a service entirely. The daemon is optional; the CLI and the library do all the work.

How it works

Files are hashed on scan. Unchanged files are skipped, changed files are re-indexed, and deleted files are removed in the same transaction. SQLite’s FTS5 handles tokenization, ranking, and prefix queries.

let mut index = sift::Index::open("notes.db")?;
index.sync("./notes")?;

let hits = index.search("edge cache invalidation", 20)?;
for hit in hits {
    println!("{}  {}", hit.score, hit.path);
}

Ranking blends BM25 with a small recency prior. Headings and filenames get a modest boost, which matters more than it sounds: when searching notes, you often remember what a document was called before you remember what it said.

Details that took longer than expected

  • Unicode tokenization. CJK text needs a different tokenizer than English. FTS5 supports both, but a mixed corpus needs a per-document decision.
  • Incremental writes. A naive sync rewrites the whole index on any change. Batching into one write transaction per scan made a 40,000-note vault feel instant.
  • A WASM build. The same Rust core compiles to WebAssembly and indexes uploaded files in the browser. It shares the code and the query syntax, so the demo behaves exactly like the local tool.

Result

A 40,000-note vault indexes in under four seconds and returns results in about 15ms. The index file is roughly a tenth the size of the source text.