Local code and markdown search tool built on Tantivy
Project description
tantivy-search
Local code and markdown search tool built on Tantivy. Indexes directories for fast BM25 keyword search across code and markdown files.
Features
- BM25 search with hybrid exact (5x boosted) + fuzzy matching
- Field boosts: title (3x), heading_path (2x), content (1x)
- Language-aware chunking for 30+ programming languages and markdown
- Inline filters:
lang:py,repo:myrepo,file:*.toml,after:7d(with negation) - Snippet mode for compact output, with selective expansion of individual results
Usage
# Index directories (repo name derived from directory basename)
tantivy-index ~/code/my-project ~/Documents/notes
# Search
tantivy-search "error handling lang:py"
tantivy-search "config repo:my-project f:*.toml"
tantivy-search "README lang:md"
tantivy-search "error -lang:python" # exclude a language
tantivy-search "ssh setup after:7d" # recent results only
# Snippet mode
tantivy-search "error handling" -s # compact output
tantivy-search "error handling" -n 10 -e 2,5 # expand results 2 and 5
# Index stats
tantivy-search --status
Inline filters
| Filter | Description |
|---|---|
lang:<name> |
Filter by language (python, js, ts, rust, markdown, ...) |
file:<pat> / f:<pat> |
Filter by file path substring |
repo:<name> / r:<name> |
Filter by repository name |
after:<time> / before:<time> |
Timestamp filter (24h, 7d, 2w, or 2026-03-14) |
-lang:<name> |
Exclude a language (negation works for all filters) |
Language aliases: py, md, rb, rs, sh, cs, kt.
Keeping the index up to date
tantivy-index does a full reindex of the given directories each time. For periodic reindexing, a systemd timer works well:
# ~/.config/systemd/user/tantivy-index.service
[Unit]
Description=Reindex tantivy-search
[Service]
Type=oneshot
ExecStart=%h/.local/bin/tantivy-index %h/code/my-project %h/Documents/notes
# ~/.config/systemd/user/tantivy-index.timer
[Unit]
Description=Reindex every 5 minutes
[Timer]
OnBootSec=30
OnUnitActiveSec=5min
[Install]
WantedBy=timers.target
For live reindexing (e.g. git-based change detection), see the Python API: SearchIndex.index_repo(repo_path, repo_name).
MCP server
pip install tantivy-search[mcp] adds an optional MCP server. Add to your Claude Desktop / Claude Code config:
{
"mcpServers": {
"tantivy-search": {
"command": "tantivy-search-mcp"
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tantivy_search-0.1.0.tar.gz.
File metadata
- Download URL: tantivy_search-0.1.0.tar.gz
- Upload date:
- Size: 122.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.5 {"installer":{"name":"uv","version":"0.11.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c4d4b615d005e2f5d9087691ce8b77d7e30b6401f974acee975b5d76cd2d3e4
|
|
| MD5 |
0bd81610c4a3f8630539aa9425ff98e7
|
|
| BLAKE2b-256 |
438d94a670aba07ba8e6bf5a7887d62b5df4d8b4ae7454fb8628992ec3ada385
|
File details
Details for the file tantivy_search-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tantivy_search-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.5 {"installer":{"name":"uv","version":"0.11.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc45fefa418938dc1e5477f0dc943d5691dd0255154c7d658cabec8698b266fa
|
|
| MD5 |
aad40d934e882326b25a6cb1960836ab
|
|
| BLAKE2b-256 |
ebff481d63844d63d1764f378f48a2fbf1a2a0d6415a0ae63d92aafbc03bd370
|