{ "info": { "author": "Adam Hopkins", "author_email": "adam@optymizer.com", "bugtrack_url": null, "classifiers": [], "description": "# elasticmanager\nA manager for translating an ORM into Elasticsearch\n\n*This package is still in active development. Currently it is being built as an mixin for the Django ORM. However, once stable, this will be abstracted away to be able to plugin to other ORMs.*\n\nThis pacakge requires `elasticsearch-dsl` which you can get:\n\n pip install elasticsearch-dsl\n\n## Getting Started\n\n1. To get started, install from pip.\n\n pip install elasticmanager\n\n1. Add `elasticmanager` to your `settings.py` (this enables management commands).\n1. Put the name of your index in `settings.py`: `ELASTICSEARCH_INDEX = 'myindex'`\n1. Subclass `elasticmanager.ElasticModel`.\n\n ```python\n from django.db import models\n from elasticmanager.models import ElasticModel\n class Visitor(ElasticModel, models.Model):\n name = models.CharField(max_lendth=100)\n created = models.DateTimeField(auto_now_add=True, editable=False)\n ```\n\n\n1. Create a `doctypes.py` in the same app as the corresponding `models.py`.\n Add a `DocType` to this file with the same name as your model. (See [Elasticsearch DSL documenation for more information on creating a `DocType`](https://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html#doctype))\n\n ```python\n from django.conf import settings\n from elasticmanager.doctypes import BaseDocType\n from . import models\n class Visitor(BaseDocType):\n\n pk = field.Keyword()\n name = field.Keyword()\n created = field.Date()\n\n class Meta:\n model = models.Visitor\n index = settings.ELASTICSEARCH_INDEX\n ```\n\n\n Note that the `Meta` information for the `doctype` should link to the `model` and the `index`.\n\n1. Run `./manage.py rebuild_mapping`\n1. Run `./manage.py rebuild_indexing` (if there are items in the DB that need to be inexed)\n\nThere is also another management command (`./manage.py remove_index `) that can be used to delete an entire index. Helpful during development stages.\n\nCurrently, all calls to the `.save()` method on an instance of the model will trigger the `.save()` on the doctype, and therefore will keep the index in Elasticsearch up to date.\n\n## Making calls to query and filter\n\nCalls somewhat approximate the default Django syntax.\n\n**Get all instances**\n\n```python\nvisitors = Visitor.elastic.all() # Return everything from Elasticsearch\n```\n\n**Get one instance**\n\n```python\nvisitor = Visitor.elastic.get(pk=123) # Return an instance from Elasticsearch given a specific key\nvisitor = Visitor.elastic.first() # Return first instance in a queryset\nvisitor = Visitor.elastic.last() # Return last instance in a queryset\n```\n\n**Count the number of instances**\n\n```python\ncount = Visitor.elastic.count() # Count the number of instances in a queryset\n```\n\n**Filter/query** *This lines up with the [query](https://elasticsearch-dsl.readthedocs.io/en/latest/search_dsl.html#queries) and [filter](https://elasticsearch-dsl.readthedocs.io/en/latest/search_dsl.html#filters) methods. See the linked documentation for more information.*\n\n```python\njohns = Visitor.elastic.filter(name=\"John\") # Return everything from Elasticsearch\n```\n\n**Chaining applies**\n\n```python\nfirst_john = Visitor.elastic.filter(name=\"John\").first()\n```\n\nUnder the hood, there is an `execute()` method that is committing the search. This can be called by itself, and probably should be if you are (for example) manipulating a queryset. But, you should not need to call that if you are, for example, calling `count()` or if you are iterating over the result set.\n\n```python\njohns = Visitor.elastic.filter(name=\"John\")\nfor john in johns:\n print(john)\n\n# or\n\njohns = Visitor.elastic.filter(name=\"John\")\njohns.execute()\nprint(johns.results)\n```\n\n*This requirement will be removed with some more fine tuning to work more intuitively.*\n\n## Plans for the future\n\n- Abstraction from using `models.Manager`\n- Fix the class factory so that a `Model` can be automatically transformed into a `DocType` without having to define it in `doctypes.py`.\n- Tests\n- Aggregations\n- Additional Exception handling\n- More management commands\n- More powerful API\n\nIf you have any questions, thoughts, complaints, compliments, let me know.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/ahopkins/elasticmanager/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ahopkins/elasticmanager", "keywords": "django,elasticsearch", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "elasticmanager", "package_url": "https://pypi.org/project/elasticmanager/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/elasticmanager/", "project_urls": { "Download": "https://github.com/ahopkins/elasticmanager/archive/master.zip", "Homepage": "https://github.com/ahopkins/elasticmanager" }, "release_url": "https://pypi.org/project/elasticmanager/0.2.6/", "requires_dist": null, "requires_python": null, "summary": "Django model manager like class for elasticsearch integration", "version": "0.2.6" }, "last_serial": 2825323, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "9a549607d01babc4bff8270500bf681d", "sha256": "7a15301b0eebdfadfab5155d85c3796ec8a2067e60920444487dae0d22d50db4" }, "downloads": -1, "filename": "elasticmanager-0.2.tar.gz", "has_sig": false, "md5_digest": "9a549607d01babc4bff8270500bf681d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3124, "upload_time": "2017-02-14T20:11:18", "url": "https://files.pythonhosted.org/packages/10/cb/3e05a54c949ab3ca342656e902d794b322698de0127e819d3cc14faa727e/elasticmanager-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "31d0ea8826f9c90316f6d3f203b82078", "sha256": "a8375209151b08eda02b849eaba3693bea2c971b581bb3c6b1303df8afdc1491" }, "downloads": -1, "filename": "elasticmanager-0.2.1.tar.gz", "has_sig": false, "md5_digest": "31d0ea8826f9c90316f6d3f203b82078", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3129, "upload_time": "2017-02-14T20:22:46", "url": "https://files.pythonhosted.org/packages/9a/3a/9ef0db65e4fe3c5a5d1f5901d75ae1375da73d2f839e3439df28cf248fc4/elasticmanager-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "33e919af1cebb5024013e27c11a01ed4", "sha256": "f70f94c8f80241eb615da4046a9e2302497638c12150f820b79f6df100fb6643" }, "downloads": -1, "filename": "elasticmanager-0.2.2.tar.gz", "has_sig": false, "md5_digest": "33e919af1cebb5024013e27c11a01ed4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8598, "upload_time": "2017-02-14T20:38:29", "url": "https://files.pythonhosted.org/packages/41/53/2866ac416e431ec83caff9c3102de88c62c4075ca0c9c3d40adb586baf25/elasticmanager-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "c0f18be9b798110a609d5f4e24f804ca", "sha256": "6b9897b3fdc8a7ea44a6e9f2160ecbb5b689fe5ce1b328364de849074143e30c" }, "downloads": -1, "filename": "elasticmanager-0.2.3.tar.gz", "has_sig": false, "md5_digest": "c0f18be9b798110a609d5f4e24f804ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8597, "upload_time": "2017-02-14T20:42:08", "url": "https://files.pythonhosted.org/packages/eb/ab/4f5437331868c82b20523cf6bd78d7804cdfe4f9ab7a4ae9bc3143f717f9/elasticmanager-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "d0dd2f68b1fe1d3a2b684c5c072db2da", "sha256": "7fb24da839e93040b8a3e51492821e84f0ff8bf263751b93e7a41ec39771c0ea" }, "downloads": -1, "filename": "elasticmanager-0.2.4.tar.gz", "has_sig": false, "md5_digest": "d0dd2f68b1fe1d3a2b684c5c072db2da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8702, "upload_time": "2017-02-22T08:09:09", "url": "https://files.pythonhosted.org/packages/dd/28/097241ebcea47a12b9cd3843b513dfd901f22fd2ac61f2a4bd31531b7941/elasticmanager-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "5d7944c776f3d2482776ceb065c119fc", "sha256": "45615e46743aee342b01d8d9b91b5900babcfd0e4ffac5dc9d371b6523852ee7" }, "downloads": -1, "filename": "elasticmanager-0.2.5.tar.gz", "has_sig": false, "md5_digest": "5d7944c776f3d2482776ceb065c119fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8711, "upload_time": "2017-02-22T08:34:56", "url": "https://files.pythonhosted.org/packages/68/7e/0b1ad53f06cf7e7b8634ef6c5700495ae66cd83f7c4443a1f5222ba89187/elasticmanager-0.2.5.tar.gz" } ], "0.2.5.1": [ { "comment_text": "", "digests": { "md5": "ffb17000d59e00f9f9161843ef0fb254", "sha256": "0c8d51323b158ce8397159ad5ad65d833be4d72a9e6cad9cbfe289dc048f52fa" }, "downloads": -1, "filename": "elasticmanager-0.2.5.1.tar.gz", "has_sig": false, "md5_digest": "ffb17000d59e00f9f9161843ef0fb254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8719, "upload_time": "2017-02-22T08:38:12", "url": "https://files.pythonhosted.org/packages/50/81/9c03f07e0a5272717eb23dab8b7b4951f40a78c2288b3d6ceeff868656df/elasticmanager-0.2.5.1.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "b85daad3e5b897059bf1379a2fd082a6", "sha256": "fc33073e5ca6d4ba96380a6c47417fb4074091de74d5edd129d6a18cecc85bc0" }, "downloads": -1, "filename": "elasticmanager-0.2.6.tar.gz", "has_sig": false, "md5_digest": "b85daad3e5b897059bf1379a2fd082a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8841, "upload_time": "2017-04-24T09:43:59", "url": "https://files.pythonhosted.org/packages/c0/58/d97a406d2dee10a6b872613467b0550d9be511834cc13fe55e490604b84d/elasticmanager-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b85daad3e5b897059bf1379a2fd082a6", "sha256": "fc33073e5ca6d4ba96380a6c47417fb4074091de74d5edd129d6a18cecc85bc0" }, "downloads": -1, "filename": "elasticmanager-0.2.6.tar.gz", "has_sig": false, "md5_digest": "b85daad3e5b897059bf1379a2fd082a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8841, "upload_time": "2017-04-24T09:43:59", "url": "https://files.pythonhosted.org/packages/c0/58/d97a406d2dee10a6b872613467b0550d9be511834cc13fe55e490604b84d/elasticmanager-0.2.6.tar.gz" } ] }