Search abstraction layer
Project description
Salinic
Salinic - provides modular search. It features a unified, familiar 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 salinic.field import IdField, KeywordField, TextField
from salinic.schema import Schema
class IndexEntity(Schema):
id: str = IdField(primary_key=True)
user_id: str
parent_id: str
title: str = TextField()
text: Optional[str] = TextField()
tags: list[str] | None = 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 = IndexEntity(
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(IndexEntity).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.2.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file salinic-0.2.2.tar.gz
.
File metadata
- Download URL: salinic-0.2.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca321e7ef7512be518a081405fbdc7cf04ab2f650e2a7b4178d585935075751d |
|
MD5 | 8bc0143bac323fecf819bdc761799df2 |
|
BLAKE2b-256 | c725f6c9163411efbc166b44399fe32860ab14a22cd4067c2a2f5f0609ab4a64 |
File details
Details for the file salinic-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: salinic-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8bd615cc1630bb793a9c5f6312570aae0caa622b60a2ed7416cc910b1856d6b |
|
MD5 | 31b8404d692d6ab078b8803779a2f645 |
|
BLAKE2b-256 | ecd9aac37356a7c2028c10cb25b168537c1ba7dfe0f2b34521f154cfa5279ced |