TreeSearch Rust CLI
treesearch is a fast, structure-aware document search CLI built with Rust.
It indexes files into a local SQLite FTS5 database and searches by document
structure instead of chunking text into arbitrary fragments.
This crate publishes the ts executable.
Install
Prebuilt binaries are also published on GitHub Releases:
- Linux:
x86_64-unknown-linux-gnu - macOS Intel:
x86_64-apple-darwin - macOS Apple Silicon:
aarch64-apple-darwin - Windows:
x86_64-pc-windows-msvc
Release page:
https://github.com/shibing624/TreeSearch/releases
Why TreeSearch
- No embeddings
- No vector database
- No chunk splitting
- SQLite FTS5 with persistent local indexes
- Structure-aware retrieval for Markdown, text, code, HTML, and more
Quick Start
Search the current directory with the default auto mode:
Build the index explicitly:
Inspect index stats:
Wildcard Queries
ts supports a narrow set of wildcard shortcuts:
auth*: prefix match*auth*: contains-style regex match- other wildcard shapes currently fall back to regular query parsing
For explicit control:
ts --regex "o?auth" .treats the query as a raw regexts search --regex "o?auth"runs indexed search in regex modets --fts-expression "auth*" .passes a raw FTS5 expressionts search --fts-expression "auth*"runs indexed search with raw FTS5 syntax- Invalid regex patterns raise an explicit error instead of silently returning no results
Examples:
Search Modes
ts supports three search modes:
auto: default mode, automatically selectsflatortreeflat: force FTS-style flat retrievaltree: force tree traversal retrieval
Examples:
In auto mode, TreeSearch uses the same three-layer decision logic as the
Python version:
- Source type mapping: file types that benefit from tree search are marked explicitly.
- Depth verification: only documents with real structure depth are treated as hierarchical.
- Ratio threshold: if enough indexed documents benefit from tree mode, use
tree; otherwise useflat.
Commands
ts [OPTIONS] [QUERY] [PATH]
ts search <QUERY> [PATH]
ts index [PATH]
ts stats [PATH]
Useful options:
--mode auto|flat|tree--format tty|json|plain--json--follow-n, --max-results <N>
Output Formats
tty: colored terminal outputjson: machine-readable JSON outputplain: plain text output
Documentation
- Project homepage: https://github.com/shibing624/TreeSearch
- API docs: https://docs.rs/treesearch
License
Apache-2.0