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.1.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file salinic-0.1.0.tar.gz
.
File metadata
- Download URL: salinic-0.1.0.tar.gz
- Upload date:
- Size: 6.4 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 | 10ca081c4f9aa0dc305a992c8d9a7149d6bf08070eae32c7967ba31d358f242f |
|
MD5 | 0e6ae185a44ed2bb80c2bd4bc23aead0 |
|
BLAKE2b-256 | d6984fc63bc701eb21f66663702985950e7b32ae4cdba3ca48d840e206e41555 |
File details
Details for the file salinic-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: salinic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 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 | 9a1d2fd0227447d8ec1a51fed6c1076fff681b26b39bc95afb12ede1925a99a4 |
|
MD5 | f462985015653ef234d89ddc299e48cb |
|
BLAKE2b-256 | b1c9ec2c4815cb72fb8535828ddede8297d9f3ebe66c6681f0a33dd405b7ba0b |