Search abstraction layer
Project description
Salinic
Salinic - provides modular search. It features a unified API that allows you to plug in different search backends. Currently, it supports only Xapian backend.
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 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 Session, create_engine
engine = create_engine("xapian:////search_index")
session = Session(engine)
for document in all_your_documents():
entity = Index(
id=str(document.id),
user_id=str(document.user_id),
parent_id=document.parent_id,
title=document.title,
text=document.text,
tags=document.tags
)
session.add(entity)
Search your documents:
from salinic import Session, create_engine
engine = create_engine("xapian:////search_index")
session = Session(engine)
sq = Search(Index).query(" your query string ")
for found in session.exec(sq):
print(found) # found is instance of IndexEntity
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
salinic-0.2.7.tar.gz
(9.7 kB
view details)
Built Distribution
salinic-0.2.7-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file salinic-0.2.7.tar.gz
.
File metadata
- Download URL: salinic-0.2.7.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fee3e74a125b7ebe381fc3fee0278c38a3abec115ac5a944a41d11892d19282 |
|
MD5 | 5c9963316724efa1dacd29d71d1ebae3 |
|
BLAKE2b-256 | fe9ee2466bff6171b07a7b53b507f16d7de0a013a183dba91e1ee706af69847d |
File details
Details for the file salinic-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: salinic-0.2.7-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31d7f0e2868e4b9caacf1b61a720cc93a6bf7ac2ff39ca8b90492cfcdcce3d47 |
|
MD5 | efd3719e3e4d87190618e230418d3d4f |
|
BLAKE2b-256 | d9c32c41374095194d24809fc94a04b24cea552d2fc39e1ce3111f0f68933094 |