Skip to main content

Tests

Salinic

Salinic - provides modular search. It features a unified API that allows you to plug in different search backends. Currently, it supports Xapian and Solr backends.

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 MyModel(Schema):
    """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 IndexRW, create_engine

    engine = create_engine("xapian:////search_index")
    index = IndexRW(engine, schema=MyModel)

    for document in all_your_documents():
        model = MyModel(
            id=str(document.id),
            user_id=str(document.user_id),
            parent_id=document.parent_id,
            title=document.title,
            text=document.text,
            tags=document.tags
        )
        index.add(model)

Search your documents:

    from salinic import IndexRO, create_engine

    engine = create_engine("xapian:////search_index")
    index = IndexRO(engine, schema=MyModel)

    sq = Search(MyModel).query(" your query string ")

    for found in index.search(sq):
        print(found)  # found is instance of MyModel

The only modification of your for changing to different search engine backend, is the first argument of the create_engine method e.g. from "xapian:////search_index" to "solr://localhost:8983/my-index-name".

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salinic-0.4.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: salinic-0.4.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1021-azure

File hashes

Hashes for salinic-0.4.0.tar.gz
Algorithm Hash digest
SHA256 19d2e9fa5810a90013eaae9641e6af02303ffd3d4239e69bfd72cfe8eb13ca7b
MD5 d9d8e026c408ea8db19ba198cfa83a43
BLAKE2b-256 7552aa7b6c2a3fa3b58948e2103c657bbc366019f6bc95c0d78fc2279b7c9a14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: salinic-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1021-azure

File hashes

Hashes for salinic-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72321a6f4a56bfef8a918f577df210da3441624d30568f14f21ee6861d591966
MD5 f04a7dfb77690353819b342fef26e772
BLAKE2b-256 f2859094435336c64a3d123125282dc575c3d46f6ddfa8f60803a41cae7a8111

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

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