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.4.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file salinic-0.2.4.tar.gz
.
File metadata
- Download URL: salinic-0.2.4.tar.gz
- Upload date:
- Size: 7.2 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 | 8c9388c9922030df849198efcecea02f757b67e316f457b58e5ded020b2f7a9a |
|
MD5 | 41397bfa12f18af825b94b082e096104 |
|
BLAKE2b-256 | 08587d63d0f241aa14f2a8554e08347eb361525fd9beff550837e4dab3ad48bf |
File details
Details for the file salinic-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: salinic-0.2.4-py3-none-any.whl
- Upload date:
- Size: 9.4 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 | ded5cf4a7d33cc1af2443215c362940f9a9340fdf35fa8abb716cc7beb14aeb9 |
|
MD5 | 1ee6a8b9b30e1e3dd6cb6838956ea683 |
|
BLAKE2b-256 | 871fb4dc1cb3a8a23a27807d06d2be81912c7fc2d18af479db2dfd9abd54e760 |