Skip to main content

No project description provided

Project description

Build Status License: MIT


Python bindings for Tantivy.


The bindings can be installed using from pypi using pip:

pip install tantivy

If no binary wheel is present for your operating system the bindings will be build from source, this means that Rust needs to be installed before building can succeed.

Note that the bindings are using PyO3, which requires rust nightly and only supports python3.


Setting up a development enviroment can be done in a virtual environment using pipenv or using local packages using the provided Makefile.

For the pipenv setup install the virtual environment and build the bindings using:

pipenv install --dev
pipenv run maturin develop

After the bindings are build, the tests can be run using:

pipenv run python -m pytest

For the Makefile based setup run:


Running the tests is done using:

make test


The Python bindings have a similar API to Tantivy. To create a index first a schema needs to be built. After that documents can be added to the index and a reader can be created to search the index.

import tantivy

# Declaring our schema.
schema_builder = tantivy.SchemaBuilder()
schema_builder.add_text_field("title", stored=True)
schema_builder.add_text_field("body", stored=True)
schema =

# Creating our index (in memory, but filesystem is available too)
index = tantivy.Index(schema)

# Adding one document.
writer = index.writer()
    title=["The Old Man and the Sea"],
    body=["""He was an old man who fished alone in a skiff in the Gulf Stream and he had gone eighty-four days now without taking a fish."""],
# ... and committing

# Reload the index to ensure it points to the last commit.
searcher = index.searcher()
query = index.parse_query("fish days", ["title", "body"])

(best_score, best_doc_address) =, 3).hits[0]
best_doc = searcher.doc(best_doc_address)
assert best_doc["title"] == ["The Old Man and the Sea"]

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-0.13.2.tar.gz (25.0 kB view hashes)

Uploaded source

Built Distributions

tantivy-0.13.2-cp38-none-win_amd64.whl (1.6 MB view hashes)

Uploaded cp38

tantivy-0.13.2-cp37-none-win_amd64.whl (1.6 MB view hashes)

Uploaded cp37

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page