No project description provided
Project description
Minisearch
Minisearch is a lightweight, local full-text search library for Python written in Rust with no external Python dependencies. It provides a simple API for indexing text and running ranked searches without external services or infrastructure.
Installation
pip install minisearch
Documentation
Query language
Queries are parsed as phrases; term order matters even without quotes. Each term can include optional fuzziness, and phrases can include a slop value.
Examples
-
Phrase query:
python searchor"python search"returns: documents where the terms appear as an exact phrase. -
Term with fuzziness:
pyth~1 search~2returns: documents that match the phrase in order, allowing per-term fuzziness. -
Phrase with slop:
"full text search"~2returns: documents where the phrase terms appear within a slop window of 2 positions.
Notes:
- Fuzziness (
~N) applies to individual terms and allows minor spelling differences. - Slop (
"..."~N) applies to phrases and allows terms to appear within N positions of each other. - Fuzziness is limited to 0-2 per term.
- Slop is limited to 0-99.
Adding/Deleting indexes
An index is a named handle that points at an on-disk directory. You can create multiple indexes in one process using MiniSearch.
from minisearch import MiniSearch
search = MiniSearch()
created, index = search.add("wikipedia", "./data")
# remove handle only (does not delete data on disk)
search.delete("wikipedia")
MiniSearch.add() returns (created, index) where created is True if the index was created for the first time in the current process.
Adding, deleting, getting documents
Documents are added as strings and are tokenized, stemmed, and indexed.
from minisearch import MiniSearch
search = MiniSearch()
_, index = search.add("demo", "./data")
with index.session():
doc_id = index.add("The quick brown fox")
index.add("The quick brown fox jumps")
# fetch by ULID
_doc = index.get(doc_id)
Best practice: use index.session() when inserting or deleting many documents. The session ensures buffered data is flushed to disk on exit, reducing the risk of data loss if the process stops before an explicit flush().
Running queries
Index.search() returns a list of results ordered by score. Each result contains a score and a document. Document content is fetched lazily.
results = index.search("\"quick fox\"~1", top_k=5)
for r in results:
print(r.score, r.document.content)
top_k=0 returns all matches; otherwise the results are capped to the top K.
Flush and merge
flush() persists buffered writes (documents, index logs, metadata). It is automatically called when a session exits.
merge() compacts old segments by removing deleted documents. Use it after many deletes to reclaim space and improve search speed.
Caveat: because documents are loaded lazily, a merge can invalidate previously fetched Document handles that still point at old segment locations. Fetch new documents after a merge.
Settings
Minisearch can be configured via a TOML file passed to Index / MiniSearch.
search = MiniSearch(conf="./minisearch.toml")
_, index = search.add("demo", "./data")
Example minisearch.toml:
# segment storage size
segment_size = 52428800
# buffer size before flush
documents_buffer_size = 1048576
# seconds before auto flush
documents_save_after_seconds = 5
# segment compaction threshold
merge_deleted_ratio = 0.3
# search metadata
metadata_save_after_operations = 100000
metadata_save_after_seconds = 10
# index logs
index_buffer_size = 1048576
index_save_after_operations = 100000
index_save_after_seconds = 5
# custom stop words
stop_words = ["a", "the", "and"]
All fields are optional; missing fields use defaults.
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 minisearch-1.0.1.tar.gz.
File metadata
- Download URL: minisearch-1.0.1.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33fc044a5af867ad65d3ea51f0321c70406e591a9d8a8afea9b7536cc28526a5
|
|
| MD5 |
bab0a3406aaede21cb0b1fcf3651b7a5
|
|
| BLAKE2b-256 |
124f16ef2ea7e2b7ef969b9f68bac1cb47887766bac65f450b6e87fd8e1cc76a
|
File details
Details for the file minisearch-1.0.1-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 472.8 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c2be27ce68f507945a3a542238a833515c4b93d5f16d74e821b0fe854a7fc07
|
|
| MD5 |
366debce290a5a3e40320d1017731605
|
|
| BLAKE2b-256 |
819a9be04c1c75ef587f3c479c66a3a574f6b11185647153a0a6ab54027246bf
|
File details
Details for the file minisearch-1.0.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 635.0 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02a1a7fda1bd247510ad4d27fc0221685aa694ad5b7b4486fc7330a6c442481c
|
|
| MD5 |
b3d9a9fa89ebcfbd1e34fb355b844679
|
|
| BLAKE2b-256 |
e9e715b637d08af200a4c2cc54b673a383e84a6c339ba9bc85927acbf14c8744
|
File details
Details for the file minisearch-1.0.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 615.0 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cde4ac24d5f5fb8d13e85273880866c71ad54001c64fa5aa67c416b629677b7
|
|
| MD5 |
a34446e14d13edbca85ccc8be17957a1
|
|
| BLAKE2b-256 |
c47c0dc5aed51da92002ec694a1ee92893b1fbdfaceb1466f8fb88ae284515b4
|
File details
Details for the file minisearch-1.0.1-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 562.0 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3059fe03e459bcb90058dc7241553b68776ea74edbbcc2e02e733a3a3ec94a9d
|
|
| MD5 |
3fd3eb465a2b8cae38ff0f0df5a0d758
|
|
| BLAKE2b-256 |
9d5ad8076984202366d90dfc2aa2f81d7a3d464aa714ec9ff786df6ae05204cc
|
File details
Details for the file minisearch-1.0.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 476.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee4fd8ff1edc2216e10ccaa6ddb0a29929dff90c68d140a9f7c87bab4e5d19aa
|
|
| MD5 |
3d466c1787d01305e79b2d5c3b61bc21
|
|
| BLAKE2b-256 |
b88acf09b65a755fc974700d37828b29775450ccd4cecd2e426d2ccac444fc37
|
File details
Details for the file minisearch-1.0.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 634.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2ee3dbba3377d34596b751ecf33e80bec86c90bb54dc1bc855755b7b2e49104
|
|
| MD5 |
1a5a90bfe50433a8d03a002c73e23493
|
|
| BLAKE2b-256 |
c42c0aecdf2c912fba407536bff8c87cd032138c200236cd83a9114fc08bde42
|
File details
Details for the file minisearch-1.0.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 614.7 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3bcadcae082975c73090f1a2e67a3ebbc0c534ff3dbfcfaa5dba5d0b55f954e
|
|
| MD5 |
b0b99f02e870e8b2a7019ce320531f2d
|
|
| BLAKE2b-256 |
995eadd47a2d981d5d8039d93926821b773542a52d1410533860c1515b878aed
|
File details
Details for the file minisearch-1.0.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 562.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2dc237ca5ac43d1e4ba1cb95a61717c778ff0b01430deadbf5a14dde045781
|
|
| MD5 |
448836f4413380f7c57fde028b113dd3
|
|
| BLAKE2b-256 |
53d9eb913a0c7b9457c903ebf97a31b5235f63ad35f4eff05215ff8f517b9b70
|
File details
Details for the file minisearch-1.0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 476.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c205efcea681ffd7da313b90bd6a9c43697a545f1faa663b71e5897852f9b7c9
|
|
| MD5 |
676f68673d56445bcb735218c26c690a
|
|
| BLAKE2b-256 |
484676f05952e6a741a094ace89cabd5e4ebec329068dd2e308c9b34a0079081
|
File details
Details for the file minisearch-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 634.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f65fc272a40119f5a9688e7c74d3c52ef01c075ba21ead0af30518ab9d8ae16
|
|
| MD5 |
5b6f7516c9f1a962678188d0d79e654c
|
|
| BLAKE2b-256 |
724fe21d809788c1e9f461a2501d042674ccf1c056f8842c87b29a0089c72930
|
File details
Details for the file minisearch-1.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 614.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba39e3cdd407bc646ecd7d682e287350118cbcd6f78df489c9fa8b91bce83afc
|
|
| MD5 |
3c95ad3f14be6ebbb82f4f5653142508
|
|
| BLAKE2b-256 |
3ecaadb96882656b13a0962991c4bfbdccafa6dbcccd5e86091b5e18290e85c2
|
File details
Details for the file minisearch-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 562.6 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e70d38b3c56c0e27ca353d50dd09fbdfb1febfdb5b587f4203a9b3259295478
|
|
| MD5 |
98e27b9ed526933e15d75c057f2757b5
|
|
| BLAKE2b-256 |
141675880e2b5ad72d5d69fd4cb48c36e3a73df013b002399a0f0880466dae23
|
File details
Details for the file minisearch-1.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 475.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7fe3b6d3928ac4a353280d0721eb959417791b17f15b37703457d4a9befd8bc
|
|
| MD5 |
5fcc062f7c250655be2a03b0f13cfcbb
|
|
| BLAKE2b-256 |
de7d4edd0e1071033b9b7b41cd55b9df4a98100c29cc3add8bb23e59facffaf1
|
File details
Details for the file minisearch-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 635.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59db558176d0eac750718194483ca060bd5997bf3c25c30d9f5c230ad01aba6e
|
|
| MD5 |
6406fd7c6c7b94e7dd195a33585b78c1
|
|
| BLAKE2b-256 |
82d3ad130fd057b744118c8257b88d0947910f775ccad56ad566cc69dca0435e
|
File details
Details for the file minisearch-1.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 614.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37be48a82ff9fab348a8f0eabd4dc98323dcd2b89c35b9e5ea4c9a968e83d722
|
|
| MD5 |
f65e6e2e4bc74bbe9272db381fb48430
|
|
| BLAKE2b-256 |
2bf6d2d6584e641cc30fa48a3024ea70412781e2fc564014073fb0a1965124f4
|
File details
Details for the file minisearch-1.0.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: minisearch-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 562.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
771b7e7f7271584e59bf533b32bf0735798a087e5bcdb02b517386e1ff55f562
|
|
| MD5 |
94ab5fb74dd9bdde91c5177105b9262d
|
|
| BLAKE2b-256 |
c1f922e46809641c4b767bc384675bdf16490216c7bf0e16373de2f2c9a01f04
|