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.1.tar.gz (126.6 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.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tantivy_search-0.3.1.tar.gz
  • Upload date:
  • Size: 126.6 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.1.tar.gz
Algorithm Hash digest
SHA256 037587a46be8782e2f1ab88d9687ec90aeb88b7e2bec4d0ba3bf15691b06370e
MD5 37c6f16759266f86b8ce8271ad5e8f09
BLAKE2b-256 3b4b9a59c19f714263faf85591ffd5a8b752652729c3c18d3556437261dedb33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tantivy_search-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06b5db25d40d0079f85e009252811ec2cfc54b46925d1ebc867001697d86f859
MD5 d67390076fba9f90fc8d8ed429bb1fb7
BLAKE2b-256 5ab502eeaf09e6db85ea9a428b922c96a9ff0c118028df748d0de090532aa168

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