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

Uploaded Source

Built Distribution

salinic-0.2.6-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: salinic-0.2.6.tar.gz
  • Upload date:
  • Size: 9.6 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.6.tar.gz
Algorithm Hash digest
SHA256 ac7c1cee8ba84c2d7cac783b5d1d06841bc03403bccc46c490e55b9b80a4a940
MD5 e92d935500c5d62243f8c60842ffee1d
BLAKE2b-256 222202b330870e1780f4c07f123eebd1093a7dddbde8233a05f01b60f86263f3

See more details on using hashes here.

File details

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

File metadata

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

Hashes for salinic-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8fc80dc00bb5265beeb086dd934b7a08cb8427dae7515733bc53cf19ad4393b0
MD5 7126a65757b40afbec9373bd25d9ebb4
BLAKE2b-256 a4725d4baf6fb8d47fd7dc310d7c8b44ed6782ab2b11b1e3b2f159176b157a3d

See more details on using hashes here.

Supported by

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