Skip to main content

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

# 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
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tantivy_search-0.2.1.tar.gz (123.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tantivy_search-0.2.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file tantivy_search-0.2.1.tar.gz.

File metadata

  • Download URL: tantivy_search-0.2.1.tar.gz
  • Upload date:
  • Size: 123.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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

Hashes for tantivy_search-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f8dd80b5a4484fe594d2ccd0248488b6d1d6c2257a03390928d97ffe5a7af735
MD5 08af448f7e686d276759d06dadf46d73
BLAKE2b-256 9b51c9b1a6fafbdc6ae0089de838b3fb203a33526d5a2b9bb3c40a3524f0c398

See more details on using hashes here.

File details

Details for the file tantivy_search-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tantivy_search-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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

Hashes for tantivy_search-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8eaa98b9365248a02944a491d3e7004faf4be7f1b545a7300095cd0ede656cbe
MD5 6f4c7bff5e1f87b211beaf15a9382d2e
BLAKE2b-256 d0e92aef24dab40e7f4f8b01e6863843dead35294a58cee639950c22add6e77d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page