Skip to content

Full-Text Search

Reflex’s core search mode uses trigram indexing — the same technique behind Google Code Search and Zoekt. Every query finds every matching occurrence, not just definitions or references.

A trigram is a sequence of three consecutive characters. When Reflex indexes your code, it extracts every trigram from every file and builds an inverted index mapping each trigram to the files that contain it.

For a query like handleRequest:

  1. Reflex extracts trigrams: han, and, ndl, dle, leR, eRe, Req, equ, que, ues, est
  2. Looks up each trigram in the inverted index to get candidate files
  3. Intersects the candidate lists (AND operation) — only files containing all trigrams survive
  4. Scans the candidates to verify actual matches and extract line numbers

This narrows the search space by 100–1000x before any file scanning, which is why queries run in single-digit milliseconds on most codebases.

Terminal window
# Simple text search
rfx query "handleRequest"
# Case-sensitive by default
rfx query "HandleRequest" # different from above
# Phrases with spaces
rfx query "function validate"
Terminal window
rfx query "import" --lang typescript
rfx query "use " --lang rust
Terminal window
rfx query "TODO" --paths "src/api/"
Terminal window
rfx query "error" --limit 20

Long-running queries can be capped:

Terminal window
rfx query "a]" --timeout 5

The default timeout is 30 seconds.

A typical result looks like:

src/auth/handler.rs:42 pub fn authenticate(creds: &Credentials) -> Result<Session> {

Format: file:line matching_line_content

Results are sorted by file path, then line number.

Codebase sizeTypical query time
Small (< 1,000 files)2–3ms
Medium (1,000–10,000 files)10–50ms
Large (60,000+ files, e.g. Linux kernel)100–250ms

Performance comes from three techniques:

  • Trigram indexing — eliminates most files before scanning
  • Memory-mapped I/O — OS-level caching of index and content files
  • Incremental indexing — blake3 hashing detects changes instantly
Use caseMode
Find all occurrences of a stringFull-text search (this page)
Find only definitions (functions, classes)Symbol search
Pattern matching with wildcardsRegex search
Structural code patternsAST patterns