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.0.tar.gz (123.1 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.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tantivy_search-0.2.0.tar.gz
  • Upload date:
  • Size: 123.1 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.0.tar.gz
Algorithm Hash digest
SHA256 03cdcf2206ff9d9cdd2478cf5b9d421b79bfac0619d4f1bc682acc3505a58cc8
MD5 1f1e060b3827990752d74aaac31ce3e0
BLAKE2b-256 f49130b92fc83e8d6da3a3ae6a1b4082d9e59ebff0df945b654c912b42ca8fc9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tantivy_search-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49471069f2113954284482f368c7dd0fc2f4d5bf0eff6ae146912d1631043acc
MD5 0ab6eb8c0e8b97d56f34bb4596528dc9
BLAKE2b-256 4318c584dbd75c143d2f401294148dac34cc4fa893e08627c18339f035ab5ef8

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