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

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.3.0.tar.gz (125.8 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.3.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tantivy_search-0.3.0.tar.gz
  • Upload date:
  • Size: 125.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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.3.0.tar.gz
Algorithm Hash digest
SHA256 5a2338f4f3360f171b4302d45ba0a2fdbde523b347b76be66ebd1cfbe0e16c8f
MD5 56c36130716f2dbe65a2859b00e39241
BLAKE2b-256 abd2a5e625ad8b9befcd0a1b1642e470dabd9a15c056de904ad7ac967c7902ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tantivy_search-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45387a4aaa8df7dcce70561159a2345c25e61514540c56198896b5454954503e
MD5 6fce66dbc2796ec58d19463746f991d7
BLAKE2b-256 2edbf59e5374812fb9ed5b7cec202a2d204610bd02e8ab44d09128bcdfd5ea69

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