Python bindings for the Laurus search library
Project description
laurus-python
Python bindings for the Laurus search engine. Provides lexical search, vector search, and hybrid search from Python via a native Rust extension built with PyO3 and Maturin.
Features
- Lexical Search -- Full-text search powered by an inverted index with BM25 scoring
- Vector Search -- Approximate nearest neighbor (ANN) search using Flat, HNSW, or IVF indexes
- Hybrid Search -- Combine lexical and vector results with fusion algorithms (RRF, WeightedSum)
- Rich Query DSL -- Term, Phrase, Fuzzy, Wildcard, NumericRange, Geo, Boolean, Span queries
- Text Analysis -- Tokenizers, filters, stemmers, and synonym expansion
- Flexible Storage -- In-memory (ephemeral) or file-based (persistent) indexes
- Pythonic API -- Clean, intuitive Python classes with full type information
Installation
pip install laurus
To build from source (requires Rust toolchain):
pip install maturin
maturin develop
Quick Start
import laurus
# Create an in-memory index
index = laurus.Index()
# Index documents
index.put_document("doc1", {"title": "Introduction to Rust", "body": "Systems programming language."})
index.put_document("doc2", {"title": "Python for Data Science", "body": "Data analysis with Python."})
index.commit()
# Search with a DSL string
results = index.search("title:rust", limit=5)
for r in results:
print(f"[{r.id}] score={r.score:.4f} {r.document['title']}")
# Search with a query object
results = index.search(laurus.TermQuery("body", "python"), limit=5)
Index Types
In-memory (ephemeral)
index = laurus.Index()
File-based (persistent)
schema = laurus.Schema()
schema.add_text_field("title")
schema.add_text_field("body")
schema.add_hnsw_field("embedding", dimension=384)
index = laurus.Index(path="./myindex", schema=schema)
Query Types
| Query class | Description |
|---|---|
TermQuery(field, term) |
Exact term match |
PhraseQuery(field, [terms]) |
Ordered phrase match |
FuzzyQuery(field, term, max_edits) |
Approximate term match |
WildcardQuery(field, pattern) |
Wildcard pattern match (*, ?) |
NumericRangeQuery(field, min, max) |
Numeric range (int or float) |
GeoQuery(field, lat, lon, radius_km) |
Geo-distance radius search |
BooleanQuery(must, should, must_not) |
Compound boolean logic |
SpanNearQuery(field, [terms], slop) |
Proximity / ordered span match |
VectorQuery(field, vector) |
Pre-computed vector similarity |
VectorTextQuery(field, text) |
Text-to-vector similarity (requires embedder) |
Hybrid Search
request = laurus.SearchRequest(
lexical_query=laurus.TermQuery("body", "rust"),
vector_query=laurus.VectorQuery("embedding", query_vec),
fusion=laurus.RRF(k=60.0),
limit=10,
)
results = index.search(request)
Fusion algorithms
| Class | Description |
|---|---|
RRF(k=60.0) |
Reciprocal Rank Fusion (rank-based, default for hybrid) |
WeightedSum(lexical_weight=0.5, vector_weight=0.5) |
Score-normalised weighted sum |
Text Analysis
syn_dict = laurus.SynonymDictionary()
syn_dict.add_synonym_group(["ml", "machine learning"])
tokenizer = laurus.WhitespaceTokenizer()
filt = laurus.SynonymGraphFilter(syn_dict, keep_original=True, boost=0.8)
tokens = tokenizer.tokenize("ml tutorial")
tokens = filt.apply(tokens)
for tok in tokens:
print(tok.text, tok.position, tok.boost)
Examples
Usage examples are in the examples/ directory:
| Example | Description |
|---|---|
| quickstart.py | Basic indexing and full-text search |
| lexical_search.py | All query types (Term, Phrase, Boolean, Fuzzy, Wildcard, Range, Geo, Span) |
| vector_search.py | Semantic similarity search with embeddings |
| hybrid_search.py | Combining lexical and vector search with fusion |
| synonym_graph_filter.py | Synonym expansion in the analysis pipeline |
| search_with_openai.py | Cloud-based embeddings via OpenAI |
| multimodal_search.py | Text-to-image and image-to-image search |
Documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
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 laurus-0.5.0.tar.gz.
File metadata
- Download URL: laurus-0.5.0.tar.gz
- Upload date:
- Size: 617.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebd2d075ec33b2510889b48e3f86475a738718e5575cfd5f22e6f518bc51b5cb
|
|
| MD5 |
388293a392700206cc120f7c408bd56b
|
|
| BLAKE2b-256 |
a647bb1d879314d06ff934a82b6fe46fc54ee0a8f713fe7514148d00ef2eba7e
|
File details
Details for the file laurus-0.5.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: laurus-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 69.5 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e0d05685ea887ce8249e9123cf44b2d377e6cf7b8564b2a6f500b4c2d2c426f
|
|
| MD5 |
c3c5c982348582a3c455ed0cbcc2213b
|
|
| BLAKE2b-256 |
5e6c78943394bbd1b47ca0d39fde82d0abd3e6bba58c8634727a4f1338700c3c
|
File details
Details for the file laurus-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl.
File metadata
- Download URL: laurus-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl
- Upload date:
- Size: 69.5 MB
- Tags: CPython 3.14, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea0cdf24a79d1bcbac6f2d306c0d07269a3bf11e6db9a59b32cc5adb21dcdb9
|
|
| MD5 |
c5d13885806e8b891a5068569cf71daa
|
|
| BLAKE2b-256 |
e40a0d70824b836eb889737acbb9bbc638d8ffed11301e53322c923882a4e2fa
|
File details
Details for the file laurus-0.5.0-cp313-cp313-win_arm64.whl.
File metadata
- Download URL: laurus-0.5.0-cp313-cp313-win_arm64.whl
- Upload date:
- Size: 68.8 MB
- Tags: CPython 3.13, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ed5e6fe34956d0c224f78e7e2fb465d9eff1baa0cbdecdbd90a26154d1a97e
|
|
| MD5 |
04b38f3b810af50372b8a20f4dff4950
|
|
| BLAKE2b-256 |
03cdd1a434696ebadb084838de7d9e395f958f9c844a3a23a7a51383e86c3410
|
File details
Details for the file laurus-0.5.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: laurus-0.5.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 69.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f091d16a73d8c3ba7cc53654436f36668470e21e36761c983e98285392c7f1ea
|
|
| MD5 |
01c6c81b7cc67956422096452c41ce1b
|
|
| BLAKE2b-256 |
0db38ca777a0746d5ff0bbdd82bc416103162e60a0aec69776b4ccda5c543e1a
|
File details
Details for the file laurus-0.5.0-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: laurus-0.5.0-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 72.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72028bdb0bc9e963158cbaf017863080412a38b6109d7dcfd84bab6cd6208c66
|
|
| MD5 |
b7980949f0719e12eb892f0f1e74ea4c
|
|
| BLAKE2b-256 |
883d77a20ddb0a9769d643c3e58defdc9d64bb79a83f299592834078b1f1dd55
|
File details
Details for the file laurus-0.5.0-cp312-cp312-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: laurus-0.5.0-cp312-cp312-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 71.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26792c30207319fe564b768ad516aef2e4496cd37f4dd76840d0f749b1c5a651
|
|
| MD5 |
f54192e322e1caf76809d1f5b23d76f5
|
|
| BLAKE2b-256 |
f1aa1960023023f96fa06e4eed993ea302252f6715017a95d196466bfde535a4
|