tantivy-py

Python bindings for Tantivy, the fast full-text search engine library written in Rust.

Library
PyPI
v0.26.0
424stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
80/100Excellent
Development Activity92
Maintenance68
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture86
Code Quality82
Innovation80
Learning Curve74

tantivy-py exposes the Tantivy full-text search engine to Python. Tantivy is a fast, Lucene-inspired search library written in Rust, and these bindings (published on PyPI as tantivy) let Python applications define schemas, build inverted indexes, and run rich search queries without running a separate search server.

The library supports tokenized text fields, boolean and phrase queries, faceting, sorting, and relevance scoring, all backed by Tantivy’s high-performance Rust core via PyO3. It is well suited to embedding full-text search directly inside a Python service where a lightweight, in-process alternative to Elasticsearch or a hosted search engine is desirable.

What You Get

  • A tantivy Python module wrapping the Rust Tantivy search engine via PyO3.
  • Schema definition for text, integer, date, and facet fields plus inverted-index building.
  • A query API supporting term, boolean, phrase, and range queries with relevance scoring.
  • In-process indexing and search with no external search server to operate.

Common Use Cases

  • Adding fast full-text search to a Python application without deploying Elasticsearch.
  • Building an embedded search index over documents, logs, or catalog data.
  • Prototyping ranked search and faceting where an in-process engine is preferable to a hosted service.

Under The Hood

Architecture - The bindings are implemented in Rust under src/ using PyO3, exposing Python classes (Schema, SchemaBuilder, Index, Document, Query, Searcher) that wrap the corresponding Tantivy types; index segments are written to disk or held in RAM, and a tantivy/ Python package adds type stubs and light wrappers. Tech Stack - Rust with PyO3 and maturin for building wheels, targeting Python 3.10+; it depends on the upstream Tantivy crate for the actual indexing, tokenization, and query execution. Code Quality - The repo includes a tests/ suite, documented usage in docs/ via mkdocs, CI configuration, and a maturin/nox build workflow, reflecting a maintained bindings project tracking upstream Tantivy releases. API Design - The Python API mirrors Tantivy’s builder-oriented model: construct a schema, add documents through a writer, commit, then search with a parsed or programmatic query; it is ergonomic for Python developers though it assumes familiarity with inverted-index search concepts.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search