Name | salinic JSON |
Version |
0.6.1
JSON |
| download |
home_page | None |
Summary | Search abstraction layer |
upload_time | 2024-12-10 20:53:22 |
maintainer | None |
docs_url | None |
author | Eugen Ciur |
requires_python | <4.0,>=3.13 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[](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.13",
"maintainer_email": null,
"keywords": null,
"author": "Eugen Ciur",
"author_email": "eugen@papermerge.com",
"download_url": "https://files.pythonhosted.org/packages/f2/56/2a3cdf342aa8c0ed272a048686819f441439eef7dc79d352e9dfd24fa941/salinic-0.6.1.tar.gz",
"platform": null,
"description": "[](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.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "147a865ebda332f8a6e2e9dd74827174b14c8b5b149c77a3a5f7ca2907265fd6",
"md5": "2d89649a1bd44403de59ebd82fa4d08d",
"sha256": "01db1d2861b4fc8b4bf8e451553668479bd229eca4090155e9c760344080ebea"
},
"downloads": -1,
"filename": "salinic-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2d89649a1bd44403de59ebd82fa4d08d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.13",
"size": 16986,
"upload_time": "2024-12-10T20:53:20",
"upload_time_iso_8601": "2024-12-10T20:53:20.542459Z",
"url": "https://files.pythonhosted.org/packages/14/7a/865ebda332f8a6e2e9dd74827174b14c8b5b149c77a3a5f7ca2907265fd6/salinic-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f2562a3cdf342aa8c0ed272a048686819f441439eef7dc79d352e9dfd24fa941",
"md5": "37f977d4b4ccc4dd99481dc27e6ae2a8",
"sha256": "b88181ce18fa1a434aa39d1b7d96387605e6610c4cda681a03e9bab2a77547e9"
},
"downloads": -1,
"filename": "salinic-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "37f977d4b4ccc4dd99481dc27e6ae2a8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.13",
"size": 13201,
"upload_time": "2024-12-10T20:53:22",
"upload_time_iso_8601": "2024-12-10T20:53:22.695503Z",
"url": "https://files.pythonhosted.org/packages/f2/56/2a3cdf342aa8c0ed272a048686819f441439eef7dc79d352e9dfd24fa941/salinic-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-10 20:53:22",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "salinic"
}