salinic


Namesalinic JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummarySearch abstraction layer
upload_time2024-08-05 05:55:11
maintainerNone
docs_urlNone
authorEugen Ciur
requires_python<4.0,>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Tests](https://github.com/papermerge/salinic/actions/workflows/tests.yml/badge.svg)](https://github.com/papermerge/salinic/actions/workflows/tests.yml)

# 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".

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "salinic",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Eugen Ciur",
    "author_email": "eugen@papermerge.com",
    "download_url": "https://files.pythonhosted.org/packages/da/27/3a93902776c65a6f30bc0a7dff24d491f72027a3089f8b6af744ae580b3d/salinic-0.6.0.tar.gz",
    "platform": null,
    "description": "[![Tests](https://github.com/papermerge/salinic/actions/workflows/tests.yml/badge.svg)](https://github.com/papermerge/salinic/actions/workflows/tests.yml)\n\n# Salinic\n\nSalinic - provides modular search. It features a unified API that\nallows you to plug in different search backends.\nCurrently, it supports Xapian and Solr backends.\n\n\n## Usage\n\nDeclare your search schema:\n\n    from typing import Optional\n    from typing_extensions import Annotated\n\n    from salinic.field import IdField, KeywordField, TextField\n    from salinic.schema import Schema\n\n\n    class MyModel(Schema):\n        \"\"\"Index schema\"\"\"\n        id: Annotated[str, IdField(primary_key=True)]\n        user_id: str\n        parent_id: str\n        title: Annotated[str, TextField()]\n        text: Annotated[Optional[str], TextField()] = None\n        tags: Annotated[Optional[list[str]], KeywordField()] = []\n\n\nIndex your documents:\n\n        from salinic import IndexRW, create_engine\n\n        engine = create_engine(\"xapian:////search_index\")\n        index = IndexRW(engine, schema=MyModel)\n\n        for document in all_your_documents():\n            model = MyModel(\n                id=str(document.id),\n                user_id=str(document.user_id),\n                parent_id=document.parent_id,\n                title=document.title,\n                text=document.text,\n                tags=document.tags\n            )\n            index.add(model)\n\n\nSearch your documents:\n\n        from salinic import IndexRO, create_engine\n\n        engine = create_engine(\"xapian:////search_index\")\n        index = IndexRO(engine, schema=MyModel)\n\n        sq = Search(MyModel).query(\" your query string \")\n\n        for found in index.search(sq):\n            print(found)  # found is instance of MyModel\n\n\nThe only modification of your for changing to different search\nengine backend, is the first argument of the `create_engine` method e.g. from\n\"xapian:////search_index\" to \"solr://localhost:8983/my-index-name\".\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Search abstraction layer",
    "version": "0.6.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2255843d4bd8f82b57e0b0d7b2d7882625a5c3fc88f817f49a6e0414e75b8d24",
                "md5": "ce5c3ada0a0e4bc220ebd89715b4f1cd",
                "sha256": "d2e1e4e30a207f351856d13ab580b4d0b7f6afd498a2e8b0340ead05375628a2"
            },
            "downloads": -1,
            "filename": "salinic-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce5c3ada0a0e4bc220ebd89715b4f1cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 19716,
            "upload_time": "2024-08-05T05:55:09",
            "upload_time_iso_8601": "2024-08-05T05:55:09.659349Z",
            "url": "https://files.pythonhosted.org/packages/22/55/843d4bd8f82b57e0b0d7b2d7882625a5c3fc88f817f49a6e0414e75b8d24/salinic-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da273a93902776c65a6f30bc0a7dff24d491f72027a3089f8b6af744ae580b3d",
                "md5": "794946d4f6629244f3e66ec67b5da79a",
                "sha256": "b9db7e889178874a4d808bde01f2a82282af13861afa6ffdf9dea54366dffd72"
            },
            "downloads": -1,
            "filename": "salinic-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "794946d4f6629244f3e66ec67b5da79a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 14791,
            "upload_time": "2024-08-05T05:55:11",
            "upload_time_iso_8601": "2024-08-05T05:55:11.009692Z",
            "url": "https://files.pythonhosted.org/packages/da/27/3a93902776c65a6f30bc0a7dff24d491f72027a3089f8b6af744ae580b3d/salinic-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-05 05:55:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "salinic"
}
        
Elapsed time: 0.30895s