salinic


Namesalinic JSON
Version 0.3.10 PyPI version JSON
download
home_pageNone
SummarySearch abstraction layer
upload_time2024-04-21 05:05:31
maintainerNone
docs_urlNone
authorEugen Ciur
requires_python<4.0,>=3.8
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.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Eugen Ciur",
    "author_email": "eugen@papermerge.com",
    "download_url": "https://files.pythonhosted.org/packages/4a/26/fa7df96986d10dbd094abc6bd144f50ae21230e1753a199200d823965d59/salinic-0.3.10.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.3.10",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd5e26a2bcb0a61f12b52d580df813c642f0348242f39b376547ef814063df2d",
                "md5": "fa63e5b0369105c717d0c3b235699b85",
                "sha256": "9b907ed02a60710104aeee23a76eaedc02bd8f5ef5bb3ea9991b35594ddc5282"
            },
            "downloads": -1,
            "filename": "salinic-0.3.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa63e5b0369105c717d0c3b235699b85",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 19059,
            "upload_time": "2024-04-21T05:05:29",
            "upload_time_iso_8601": "2024-04-21T05:05:29.628450Z",
            "url": "https://files.pythonhosted.org/packages/dd/5e/26a2bcb0a61f12b52d580df813c642f0348242f39b376547ef814063df2d/salinic-0.3.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a26fa7df96986d10dbd094abc6bd144f50ae21230e1753a199200d823965d59",
                "md5": "133133dfd0835f32e68bde63b3f79846",
                "sha256": "344682bb2c8ce507cc050c0c23d5967d5a2e67bbab5afd67b99bc55c66a7b47b"
            },
            "downloads": -1,
            "filename": "salinic-0.3.10.tar.gz",
            "has_sig": false,
            "md5_digest": "133133dfd0835f32e68bde63b3f79846",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 14160,
            "upload_time": "2024-04-21T05:05:31",
            "upload_time_iso_8601": "2024-04-21T05:05:31.355646Z",
            "url": "https://files.pythonhosted.org/packages/4a/26/fa7df96986d10dbd094abc6bd144f50ae21230e1753a199200d823965d59/salinic-0.3.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 05:05:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "salinic"
}
        
Elapsed time: 0.22110s