No project description provided
Project description
tantivy-py
Python bindings for Tantivy.
Installation
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.
Development
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:
make
Running the tests is done using:
make test
Usage
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 = schema_builder.build() # Creating our index (in memory, but filesystem is available too) index = tantivy.Index(schema) # Adding one document. writer = index.writer() writer.add_document(tantivy.Document( 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 writer.commit() # Reload the index to ensure it points to the last commit. index.reload() searcher = index.searcher() query = index.parse_query("fish days", ["title", "body"]) (best_score, best_doc_address) = searcher.search(query, 3).hits[0] best_doc = searcher.doc(best_doc_address) assert best_doc["title"] == ["The Old Man and the Sea"] print(best_doc)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size tantivy-0.13.2-cp36-cp36m-manylinux2010_x86_64.whl (1.7 MB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp37-cp37m-macosx_10_7_x86_64.whl (1.5 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp37-cp37m-manylinux2010_x86_64.whl (1.7 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp37-none-win_amd64.whl (1.6 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp38-cp38-macosx_10_7_x86_64.whl (1.5 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp38-cp38-manylinux2010_x86_64.whl (1.7 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp38-none-win_amd64.whl (1.6 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size tantivy-0.13.2-cp39-cp39-manylinux2010_x86_64.whl (1.7 MB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size tantivy-0.13.2.tar.gz (25.0 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for tantivy-0.13.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a97d2b00850fd2edcfa162f4206841ddab8a88a21fb0d59cfae0c343fff49a0 |
|
MD5 | 234d4f282002a991725a29d7719726bd |
|
BLAKE2-256 | 9324df5cb799451e38c1eab2cec38eb80538240098c2b4111d9ca1662e322555 |
Hashes for tantivy-0.13.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f762aecc7f0454ec4a06012ae02d0ae77bfdade4ca4165bdd791220c3107d8a7 |
|
MD5 | b7eb5e1bcfaba66110d9e10e9eb197a8 |
|
BLAKE2-256 | 9bdeb697474f29729ede5b74863a1ede2f35a2fbadf2aec17f76c24114a1b239 |
Hashes for tantivy-0.13.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a6307e33eba9640301094d3c0a6d8d493f99cd8986bc641932c4e4b0fc8a71a |
|
MD5 | 6b509b282ca72a2446a6301d782b847a |
|
BLAKE2-256 | 2814d446938556ddb160bd812af2beb318043d48cb62edd7d0be41a50633f96f |
Hashes for tantivy-0.13.2-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a055cef32c0e5cf5e01b02af5b98c5b62c06b44ee745aac982d3d4d57804a389 |
|
MD5 | d96bb315c57540ea620c8f53b8ba3250 |
|
BLAKE2-256 | 86b9ae59dbea7f4147b53b2e3625ebd9186986f8efe0e1d3dc0244cf43142d54 |
Hashes for tantivy-0.13.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca10d78aa3b5326fe016e48049271c2e843bedac281fa5046f28a320f7696b8a |
|
MD5 | 40fd71b47443b189ca288566ae7b8070 |
|
BLAKE2-256 | 13d49303d37b6671cb462a0281aa16b20615306e56f3e722db9872a0d74275c2 |
Hashes for tantivy-0.13.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a9fd6395871e1280e237801b1020e9d82abe9632ce8b38068ad940087278104 |
|
MD5 | 09613421461ff871ead83f671470cf61 |
|
BLAKE2-256 | 800bd556e58f2f82962fc244b5b6131fbf7bbce57d49fda98e8e35cd1ac1058a |
Hashes for tantivy-0.13.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09ebbbe81e516c5758a6a7dbf16f2111d63a2afeb4c3064dab4797563fc012c0 |
|
MD5 | 2b4cd2cd90a4957e6d200a7901a928ce |
|
BLAKE2-256 | e3ae8ff08ca7ce55e2d2cb38c6f25f5918d444ba4b55bbfebca3568af878acdb |
Hashes for tantivy-0.13.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4caffd13c299595751bfdf0c2170537596ce6124ae1d239d030b768eddb545e |
|
MD5 | 23c88410265f4a4665b8097e7306f138 |
|
BLAKE2-256 | 06041992147c53ed71a80add18a4048cdf32516657345791ecf92775c83e5561 |