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 IndexEntity(Schema):
    id: Annotated[str, IdField(primary_key=True)]
    user_id: str
    parent_id: str
    title: Annotated[str, TextField()]
    text: Annotated[Optional[str], TextField(default=None)]
    tags: Annotated[Optional[list[str]], KeywordField(default=None)]

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


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

Uploaded Source

Built Distribution

salinic-0.2.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: salinic-0.2.3.tar.gz
  • Upload date:
  • Size: 7.1 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.3.tar.gz
Algorithm Hash digest
SHA256 dffe405fb63c3307edf758e3f6a8ccf970840a5232795238dbb2da4b61c93e62
MD5 4358e066e74829525aea2521d1e14c1e
BLAKE2b-256 93de5fafaedf922fe51385cd08e4a7ffb5a3ad458c93df65e6b4050bbd2d8b8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: salinic-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 99a0082b43a579ec57a6766871089ae5356524a49ac2bf139563be100d927e40
MD5 cd2eb67f15254d31ebe29e8b12cdd989
BLAKE2b-256 f3d4f8a5d5acb69d845edfd1a2f1f7a848cfcb8a6fe56ec214c5e4593356db5b

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