Skip to main content

Search abstraction layer

Project description

Tests

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


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

Uploaded Source

Built Distribution

salinic-0.2.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: salinic-0.2.1.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

Hashes for salinic-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a40117c72610cbfa661ecc1479e7e022668c9171a7906452881fc186b5552972
MD5 61c67673a74f80854ba3b3002653ebca
BLAKE2b-256 6118d114f6fd5d6cae547a344457e74fe781c0faa98d545fa03270fc12b0316a

See more details on using hashes here.

File details

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

File metadata

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

Hashes for salinic-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5644a826f812edc75f5d3cab07d1134b7227c35cec95690be9065e67910ebce
MD5 a28d4a5553dfdd13cf48337e364180e8
BLAKE2b-256 5a6cbf9babd460f091096be3f60748d2aa0419fe265144d0da6552a3d80882ab

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