Full-text search for Python, backed by Tantivy.
Project description
ruosh
ruosh is a full-text search library for Python. It has a Whoosh-like API, but the search engine underneath is Tantivy, which is written in Rust. The goal is to give Python code something familiar to work with while getting meaningful performance out of a real search engine.
Install
pip install ruosh
Python 3.10 or newer is required. No Rust toolchain needed , wheels are pre-built for Linux, macOS, and Windows.
Quick start
from ruosh import Schema, TEXT, ID, create_in
schema = (
Schema()
.add("doc_id", ID(stored=True, unique=True))
.add("title", TEXT(stored=True))
.add("body", TEXT(stored=True))
)
idx = create_in("my-index", schema)
w = idx.writer()
w.add_document(doc_id="1", title="Getting started", body="A short introduction to full-text search.")
w.add_document(doc_id="2", title="Advanced queries", body="Boolean, phrase, and field-specific queries.")
w.commit()
for hit in idx.search("introduction"):
print(hit["doc_id"], hit["title"], hit.score)
Queries
String queries search all text fields:
results = idx.search("full-text search", limit=10)
Structured queries let you be specific:
from ruosh.query import Term, And, Or, Phrase
# must contain both terms in the body field
results = idx.search(And(Term("body", "search"), Term("body", "fast")), limit=10)
# exact phrase
results = idx.search(Phrase("body", ["full-text", "search"]), limit=10)
Pagination
page2 = idx.search("search", limit=10, offset=10)
print(f"{page2.total} total hits, showing {len(page2)}")
Snippets
Pass snippet_fields to get highlighted excerpts back with each hit:
results = idx.search("search", limit=10, snippet_fields=["body"])
for hit in results:
print(hit.snippet("body")) # returns HTML with <b> tags around matches
Sorting
Add a numeric field with sortable=True and pass sort_by:
from ruosh import NUMERIC
schema = Schema().add("doc_id", ID(stored=True)).add("body", TEXT(stored=True)).add("rank", NUMERIC(stored=True, sortable=True))
# ...index documents...
results = idx.search("search", sort_by="rank", sort_desc=False)
Corpus intelligence
ruosh maintains a lightweight sidecar that tracks approximate term frequencies across the corpus. It updates at write time and loads once, so repeated queries cost nothing.
# how often does "search" appear across documents?
stats = idx.term_stats("body", "search")
# {"term": "search", "estimated_doc_freq": 1840, "very_common": True}
# what are the most common terms in this field?
terms = idx.frequent_terms("body", limit=20)
# [{"term": "search", "estimated_doc_freq": 1840}, ...]
These are estimates, not exact counts. They are useful for things like query planning, stopword detection, and building tag clouds. Neither SQLite FTS5 nor Whoosh exposes a top-terms API at all.
Updating and deleting documents
# replace a document by its unique field
w = idx.writer()
w.update_document(doc_id="1", title="Updated title", body="New body text.")
w.commit()
# delete by field value
w = idx.writer()
w.delete_by_term("doc_id", "1")
w.commit()
Opening an existing index
from ruosh import open_dir
idx = open_dir("my-index")
Performance
ruosh trades raw single-query speed for richer features. Each search call crosses the Python-Rust boundary, which adds a few milliseconds of fixed overhead. For workloads that need very fast single-keyword lookups over small corpora, SQLite FTS5 will be faster. ruosh is a better fit when you need structured queries, pagination with correct totals, highlighted snippets, or corpus statistics.
Compared to Whoosh, ruosh is faster across the board. On a 100,000-document corpus:
| Scenario | ruosh | Whoosh |
|---|---|---|
| Keyword search | 8.9 ms | 43 ms |
| Boolean AND | 13 ms | 201 ms |
| Phrase query | 48 ms | 371 ms |
| Paginated results | 30 ms | 193 ms |
| Snippet extraction | 10 ms | 41 ms |
| Corpus intelligence | 0.7 ms | 5.7 ms |
Development
Requirements: Python 3.11, Rust toolchain, uv.
git clone https://github.com/biswarupghosh/ruosh
cd ruosh
uv venv .venv --python 3.11
uv sync --extra dev
uv run maturin develop
uv run pytest
To run the full feature benchmark:
uv sync --extra dev --extra bench
uv run python scripts/benchmark_features.py
License
MIT
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.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ruosh-0.1.0.tar.gz.
File metadata
- Download URL: ruosh-0.1.0.tar.gz
- Upload date:
- Size: 92.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f17a2cad198e6883f4ea58cc00cad3c349db89a3dbac661d3fcb99d036fbb0b
|
|
| MD5 |
5aee7404dc600847508cbafdbcdb52b6
|
|
| BLAKE2b-256 |
35cb3f6fb0539750321c003fdf1bae7fbd3baac3e3816b70af0c1565de5a23c3
|
Provenance
The following attestation bundles were made for ruosh-0.1.0.tar.gz:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0.tar.gz -
Subject digest:
3f17a2cad198e6883f4ea58cc00cad3c349db89a3dbac661d3fcb99d036fbb0b - Sigstore transparency entry: 1382795463
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d986ddaf1fc36acd42298e2d5a3a6246e9b6028ddd6b173e19e94bda2b8abe8
|
|
| MD5 |
f7a6c29c40e4d81e3004fe7851c207f9
|
|
| BLAKE2b-256 |
20194af843bc18a10a893453893ee3de72498f70255f93d2630d0843d41f2fbd
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp313-cp313-win_amd64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp313-cp313-win_amd64.whl -
Subject digest:
2d986ddaf1fc36acd42298e2d5a3a6246e9b6028ddd6b173e19e94bda2b8abe8 - Sigstore transparency entry: 1382795759
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88265b2885ae10b80df9ed7845f55936b2a911b2ed6855acb881bb6835786f3c
|
|
| MD5 |
4cf8dc700450a3b30ef98a6cf33c3874
|
|
| BLAKE2b-256 |
0514c5172c41c58f9bfed71d84029caded0e34c48f42cd185db383de5893b34d
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
88265b2885ae10b80df9ed7845f55936b2a911b2ed6855acb881bb6835786f3c - Sigstore transparency entry: 1382796110
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a62aa4bf03beaeea65a31671d6877a8457cc4cc34190b073b02f50b4feea611
|
|
| MD5 |
789e5b06493b073d26a4d364c51b9d79
|
|
| BLAKE2b-256 |
94a948444ada65daee5f43632bdd809097b563882f6edb0885567ff070ed0133
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp312-cp312-win_amd64.whl -
Subject digest:
4a62aa4bf03beaeea65a31671d6877a8457cc4cc34190b073b02f50b4feea611 - Sigstore transparency entry: 1382796017
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96db63f2dd5ce2510360fb860e6f124b7579bd6a411a63e6082d71691b966f65
|
|
| MD5 |
b4cc13c3b0db6cbac279bd8c185ea1e3
|
|
| BLAKE2b-256 |
244561f8bde07d60437a81cdaccfa9922b4caf52a8bae21eaee2a9055b11c07e
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
96db63f2dd5ce2510360fb860e6f124b7579bd6a411a63e6082d71691b966f65 - Sigstore transparency entry: 1382795621
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ab1045523c3801a320ab17b751cb40286dffa260ee23043172cc84990944554
|
|
| MD5 |
63560310bfcc56085f65e408830fcab1
|
|
| BLAKE2b-256 |
0a9f27f9e0c1613d11e41d1f7a53c628310875cc395c021792f98f92062bd0f6
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp311-cp311-win_amd64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp311-cp311-win_amd64.whl -
Subject digest:
3ab1045523c3801a320ab17b751cb40286dffa260ee23043172cc84990944554 - Sigstore transparency entry: 1382796197
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65392f1151d51f10c9c3599539a1f5a2d1ab912726645cbb4f47733a98267563
|
|
| MD5 |
7705966d91594ffbf49a9c83925fd95d
|
|
| BLAKE2b-256 |
fe8c5cb02b918aeea51a0f7096244c9a696145872008bebda5aa8bb9d458793c
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
65392f1151d51f10c9c3599539a1f5a2d1ab912726645cbb4f47733a98267563 - Sigstore transparency entry: 1382795544
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42b77a207e978e1c7a2f7485f3a861087c260751d515867197ca8ba0fabdfc2
|
|
| MD5 |
a63c72f6c3811b02a803f91c7131e00d
|
|
| BLAKE2b-256 |
96047663d5e29ef3be86b9dc249a560cd0b9489b494dd3a92e9b4b3ffbe5c731
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp310-cp310-win_amd64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp310-cp310-win_amd64.whl -
Subject digest:
a42b77a207e978e1c7a2f7485f3a861087c260751d515867197ca8ba0fabdfc2 - Sigstore transparency entry: 1382795905
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruosh-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ruosh-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18d418057c5af650ed055898a6c848da0ece7f839c33d8378eaf202cc72683a6
|
|
| MD5 |
2586daa7659808ae570d0eae72ce23f4
|
|
| BLAKE2b-256 |
282d640889f7a611cb238f098ec2380600348ebf9ea8fdaf62e4da8839cf5dc2
|
Provenance
The following attestation bundles were made for ruosh-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on AiDinho/ruosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruosh-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
18d418057c5af650ed055898a6c848da0ece7f839c33d8378eaf202cc72683a6 - Sigstore transparency entry: 1382796297
- Sigstore integration time:
-
Permalink:
AiDinho/ruosh@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/AiDinho
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@964dd87d4a77dc1f7d4d017b946ec64c1a1f07c2 -
Trigger Event:
push
-
Statement type: