tantivy-py
Python bindings for Tantivy, the fast full-text search engine library written in Rust.
Repository Health
Technical Analysis
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
tantivyPython 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.