Skip to main content

Search abstraction layer

Project description

Tests

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


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.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

salinic-0.2.5-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file salinic-0.2.5.tar.gz.

File metadata

  • Download URL: salinic-0.2.5.tar.gz
  • Upload date:
  • Size: 9.0 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

Hashes for salinic-0.2.5.tar.gz
Algorithm Hash digest
SHA256 aa4d5529b3e07265e6d3307484b705163e4f38c428b95de955f830e1b5443ba1
MD5 cc1c33c62b8827ab8294283739e6b7e3
BLAKE2b-256 019df940b715dcb8fc4af004f94728a02dea234110d793eee56a48b199c14970

See more details on using hashes here.

File details

Details for the file salinic-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: salinic-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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

Hashes for salinic-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 937f89c4ad03b2f268029c26df3b29e784df0c29c77419dda1c7aad9967ec31d
MD5 4d124ad1680f99ba53deb266ff7e6c49
BLAKE2b-256 faad445e7d15e3d801211e66d0988d16df47cc6a7f7062faf272fec1df4bce7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page