Salinic
Salinic - provides modular search. It features a unified API that allows you to plug in different search backends. Currently, it supports Xapian and Solr backends.
Usage
Declare your search schema:
from typing import Optional
from typing_extensions import Annotated
from salinic.field import IdField, KeywordField, TextField
from salinic.schema import Schema
class MyModel(Schema):
"""Index schema"""
id: Annotated[str, IdField(primary_key=True)]
user_id: str
parent_id: str
title: Annotated[str, TextField()]
text: Annotated[Optional[str], TextField()] = None
tags: Annotated[Optional[list[str]], KeywordField()] = []
Index your documents:
from salinic import IndexRW, create_engine
engine = create_engine("xapian:////search_index")
index = IndexRW(engine, schema=MyModel)
for document in all_your_documents():
model = MyModel(
id=str(document.id),
user_id=str(document.user_id),
parent_id=document.parent_id,
title=document.title,
text=document.text,
tags=document.tags
)
index.add(model)
Search your documents:
from salinic import IndexRO, create_engine
engine = create_engine("xapian:////search_index")
index = IndexRO(engine, schema=MyModel)
sq = Search(MyModel).query(" your query string ")
for found in index.search(sq):
print(found) # found is instance of MyModel
The only modification of your for changing to different search
engine backend, is the first argument of the create_engine method e.g. from
"xapian:////search_index" to "solr://localhost:8983/my-index-name".
Release files for salinic 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| salinic-0.3.1.tar.gz | 11.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| salinic-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.9 kB
Release files / salinic-0.3.1.tar.gz
| Download URL | salinic-0.3.1.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4459df738dd9740921b26af6a7f2dec37e4d85474a150ddd2a3b86b04484db5
|
|
BLAKE2b-256 checksum How to use checksums |
1246977ecde184c96748e40c65638656754a8ac81a647fba8672723e1ea82902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
|
Release files / salinic-0.3.1-py3-none-any.whl
| Download URL | salinic-0.3.1-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c1a9132ded57d6cdc1b7a30acbf0ca527f4a0e052b4f5665a79a696d09b9d8b
|
|
BLAKE2b-256 checksum How to use checksums |
e3c7b8ee648f53eb2cc484a61306f074a762e966b069fe5cd6cfd87998ba670f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
|