Skip to main content

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 (partition name derived from directory basename)
tantivy-index ~/code/my-project ~/Documents/notes

# Search
tantivy-search "error handling lang:py"
tantivy-search "config" --path /home/user/code/my-project
tantivy-search "README lang:md"
tantivy-search "error -lang:python"          # exclude a language
tantivy-search "ssh setup after:7d"          # recent results only

# Path filter: absolute path, repeatable for OR semantics
tantivy-search "config" --path /home/user/code/my-project --path /home/user/Documents/notes

# Browse-then-expand workflow (snippets are the default)
tantivy-search "error handling" -n 10        # 10 compact snippets with indices
tantivy-search "error handling" -n 10 -e 2,5 # expand results 2 and 5 to full content

# Index stats and listing
tantivy-search --status
tantivy-search --list-paths   # tree of indexed filesystem paths with doc counts

Filters

Flag / Inline Description
--path /abs/path Absolute filesystem path. Repeat to OR multiple paths. Matches the path itself or any descendant.
-l / lang:<name> Filter by language (python, js, ts, rust, markdown, ...)
after:<time> / before:<time> Timestamp filter (24h, 7d, 2w, or 2026-03-14)
-lang:<name> Exclude a language

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"
    }
  }
}

Metadata

Release files for tantivy-search 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tantivy-search 0.3.2
File Size Uploaded
tantivy_search-0.3.2.tar.gz 127.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tantivy-search 0.3.2
File Interpreter ABI Platform
tantivy_search-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 146.4 kB

Release files / tantivy_search-0.3.2.tar.gz

Download URL tantivy_search-0.3.2.tar.gz
Size 127.9 kB
Tags Source
SHA-256 checksum
How to use checksums
94af747a022a00b556222a53a3db13a69d4a6b3dabdc435c515422f9c0adec10
BLAKE2b-256 checksum
How to use checksums
df411be2a7f931dca46d55794c27e979eb5ddfdffd977b71246fa536b1f2425a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

Release files / tantivy_search-0.3.2-py3-none-any.whl

Download URL tantivy_search-0.3.2-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
179c606277648d0fd8d11859842217b354f3b2c9ae9a2c8a9bd6defe6b6ff378
BLAKE2b-256 checksum
How to use checksums
821534ed321ca5b3d1b8ebe7643075eeabd7d971bad1bfa59f0b864dcd03389a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

Release history Release notifications | RSS feed

0.3.3

2 release files

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page