{ "info": { "author": "Matt Johnson", "author_email": "mdj2@pdx.edu", "bugtrack_url": null, "classifiers": [ "Framework :: Django" ], "description": "# Elasticmodels\n\nElasticmodels helps you index and query your Django models using elasticsearch.\nIt is designed to be an alternative to django-haystack when you need more control over\nyour index creation, and you are always going to use elasticsearch.\n\n# Install\n\n pip install elasticmodels\n\n# Setup\n\n## settings.py\n\nIn your Django settings file, define these variables:\n\n```python\n\nELASTIC_SEARCH_CONNECTION = {\n \"urls\": [\"http://localhost:9200/\"],\n \"index\": \"the_name_of_your_es_index\",\n # \"http_auth\": \"username:password\",\n}\n\n# these are used when your index is created\nELASTIC_SEARCH_SETTINGS = {\n \"settings\": {\n \"analysis\": {\n \"analyzer\": {\n \"snowball\": {\n \"type\": \"snowball\",\n \"stopwords\": \"_none_\"\n }\n }\n }\n }\n}\n```\n\nAdd elasticmodels to INSTALLED_APPS:\n\n```python\n\nINSTALLED_APPS = (\n ...\n 'elasticmodels',\n)\n```\n\n## app/search_indexes.py\n\nIn a Django app, create a search_indexes.py file, like so:\n\n```python\n\nfrom elasticmodels import Indexable\nfrom django.template.loader import render_to_string\nfrom .models import File, FileTag\n\nclass FileIndex(Indexable):\n # specify the model class this index is for\n model = File\n\n def mapping(self):\n \"\"\"\n Return the elasticsearch mapping for this model type\n \"\"\"\n return {\n \"properties\": {\n \"pk\": {\"type\": \"integer\", \"index\": \"not_analyzed\"},\n \"content\": {\"type\": \"string\", \"analyzer\": \"snowball\"},\n \"tags\": {\"type\": \"string\", \"analyzer\": \"keyword\"},\n \"org_id\": {\"type\": \"integer\", \"index\": \"not_analyzed\"},\n \"type\": {\"type\": \"integer\", \"analyzer\": \"keyword\"},\n \"uploaded_by_id\": {\"type\": \"integer\", \"analyzer\": \"keyword\"},\n }\n }\n\n def prepare(self, obj):\n \"\"\"\n Return obj transformed into a dict that corresponds to the mapping\n you defined. This is what will be indexed by elasticsearch.\n \"\"\"\n return {\n \"pk\": obj.pk,\n \"content\": render_to_string(\"files/search.txt\", {\"object\": obj}),\n \"tags\": [ft.tag.name for ft in FileTag.objects.filter(file=obj).select_related(\"tag\")],\n \"org_id\": obj.org_id,\n \"type\": obj.type,\n \"uploaded_by_id\": obj.uploaded_by_id,\n }\n```\n\n# Usage\n\n## Deleting and recreating your index\n\n ./manage.py rebuild_index\n\n**This will delete the entire elasticsearch index** and recreate it. All your\nmodel objects will be re-indexed.\n\n## Adding an individual object to the index\n\n```python\n\nfrom elasticmodels import make_searchable\n\nf = File(name=\"Foo\", type=1)\nf.save()\n\nmake_searchable(f)\n\n```\n\n## Querying\n\nYour subclass of elasticmodels.Indexable has a class attribute called `objects`\nwhich returns an elasticutils `S` instance. You can then use whatever methods are\navailable in elasticutils on the S instance.\n\nSee:\nhttp://elasticutils.readthedocs.org/en/latest/searching.html\nhttp://elasticutils.readthedocs.org/en/latest/searching.html#filters-filter\nhttp://elasticutils.readthedocs.org/en/latest/searching.html#queries-query\nhttp://elasticutils.readthedocs.org/en/latest/searching.html#advanced-filters-f-and-filter-raw\n\n```python\n\nfrom elasticutils import F\nfrom .search_indexes import FileIndex\n\nresults = FileIndex.objects.filter(F(type=1) | F(type=2)).query(content__match=\"foo\")\nfor result in results:\n print result.pk, result.content\n```\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PSU-OIT-ARC/elasticmodels", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "elasticmodels", "package_url": "https://pypi.org/project/elasticmodels/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/elasticmodels/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/PSU-OIT-ARC/elasticmodels" }, "release_url": "https://pypi.org/project/elasticmodels/0.0.10/", "requires_dist": null, "requires_python": null, "summary": "Elasticmodels helps you index and query your Django models using elasticsearch", "version": "0.0.10" }, "last_serial": 1457937, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "13c488f92f0d0dd1b91176a4bae8c1ac", "sha256": "0fbe0f6c8d3e038dd6c8df5ad3d9dcdf316faf4999521904cf13ef2dfbf99606" }, "downloads": -1, "filename": "elasticmodels-0.0.1.tar.gz", "has_sig": false, "md5_digest": "13c488f92f0d0dd1b91176a4bae8c1ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5697, "upload_time": "2014-06-11T19:45:31", "url": "https://files.pythonhosted.org/packages/f8/5f/2dd0ff8084b89d0ca2416ca4c355104905850b9aa653d788fc469ae9cdab/elasticmodels-0.0.1.tar.gz" } ], "0.0.10": [ { "comment_text": "", "digests": { "md5": "043295ba313b5b4e99e0b45899782a8f", "sha256": "c1e0e6a66b0a3908e49641259a63bf92baa9582909ee3b5509ed9cdfd9a94f81" }, "downloads": -1, "filename": "elasticmodels-0.0.10.tar.gz", "has_sig": false, "md5_digest": "043295ba313b5b4e99e0b45899782a8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6112, "upload_time": "2015-01-29T21:32:16", "url": "https://files.pythonhosted.org/packages/c8/03/988c7669e84266cb4e08babc60be9fece663a30e914a333e2deb133d92c2/elasticmodels-0.0.10.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "4339873b8825a0484e2664d23e0c3b8a", "sha256": "c493871774872c22b82bcd8f576785804e093d7e257c8073a7b009095a994cef" }, "downloads": -1, "filename": "elasticmodels-0.0.2.tar.gz", "has_sig": false, "md5_digest": "4339873b8825a0484e2664d23e0c3b8a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5698, "upload_time": "2014-06-16T20:10:39", "url": "https://files.pythonhosted.org/packages/bb/0a/c696a65c1fe707bb9e855a09eb64ac85f22d4e84cc62862b8404d9022bd6/elasticmodels-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "1b53dd3e4e17d03dff5453b8847c8ead", "sha256": "008b65b1c1b7f7b8d7c7724a26c0293606468c4aecf0831fadee3d077edef407" }, "downloads": -1, "filename": "elasticmodels-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1b53dd3e4e17d03dff5453b8847c8ead", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5951, "upload_time": "2014-07-08T21:23:40", "url": "https://files.pythonhosted.org/packages/96/e5/1a6656e4824b94972b908b07f756d4cb002f89538f1aedcfcb0ac923ca89/elasticmodels-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "166ab16a28a6cf9ef0b465d0e4fa51b3", "sha256": "5bb0e3041b695d4f5b7a8a7eacbbd19abbd55b1c56ec6bd8a744c74fa571cf31" }, "downloads": -1, "filename": "elasticmodels-0.0.4.tar.gz", "has_sig": false, "md5_digest": "166ab16a28a6cf9ef0b465d0e4fa51b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5949, "upload_time": "2014-07-16T23:11:30", "url": "https://files.pythonhosted.org/packages/e6/59/06dd8e13ac1e8c10d2cef7a70d314e4caf90e789aaa7feca8450216551e0/elasticmodels-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "617bf6c9ba20de2f619a287e6b7bfbca", "sha256": "7834d480622182120cc793de17c124befb21623bdc6f9b01dd8a73abac2975a6" }, "downloads": -1, "filename": "elasticmodels-0.0.5.tar.gz", "has_sig": false, "md5_digest": "617bf6c9ba20de2f619a287e6b7bfbca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6026, "upload_time": "2014-07-17T23:46:17", "url": "https://files.pythonhosted.org/packages/53/61/9e3626ea0c0275016e58a0baa5ed4e9bb397e98563472dd073c8afa68654/elasticmodels-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "c2c887f8a7eb01ae44c62b42fa8cffef", "sha256": "0cca7e674de611e20c235bb14a2700894446df2e80482a2cc4151ac223109d73" }, "downloads": -1, "filename": "elasticmodels-0.0.6.tar.gz", "has_sig": false, "md5_digest": "c2c887f8a7eb01ae44c62b42fa8cffef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5608, "upload_time": "2014-07-28T23:14:32", "url": "https://files.pythonhosted.org/packages/c0/f0/59674094cb73cf876a9a6f1b20c835ed596bde7684bf73a01e6d5dba131b/elasticmodels-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "415ca70d185f1c17eb219f759e16819a", "sha256": "f398e78ae9c10a31eac66c23bd4558d1998594c48881ae0ea03bea5b4e3940c0" }, "downloads": -1, "filename": "elasticmodels-0.0.7.tar.gz", "has_sig": false, "md5_digest": "415ca70d185f1c17eb219f759e16819a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5601, "upload_time": "2014-07-29T15:33:52", "url": "https://files.pythonhosted.org/packages/d6/7a/8aa4df3a5177518b5f6b9a9cfa3521a821ca89f5f5d2c01dfa418bc9a483/elasticmodels-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "2ed6338ad9c89b803560872e772ceeb5", "sha256": "ce0fbb1c35ed36409c50a3feb8dc44739d58c9bc54e3bdaa15a70f28f111fb5a" }, "downloads": -1, "filename": "elasticmodels-0.0.8.tar.gz", "has_sig": false, "md5_digest": "2ed6338ad9c89b803560872e772ceeb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5595, "upload_time": "2014-07-29T16:08:13", "url": "https://files.pythonhosted.org/packages/f5/23/f13657ecc2d9a3e101c3fb282b58a974e76cc63a8f29ad0329959e7caa38/elasticmodels-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "540ead20291a92efe3a50927f96752ce", "sha256": "82e67e5a6674164482c217d36a3aae3c7a06ccfba8935705fe445f159ddcf8df" }, "downloads": -1, "filename": "elasticmodels-0.0.9.tar.gz", "has_sig": false, "md5_digest": "540ead20291a92efe3a50927f96752ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6043, "upload_time": "2014-12-19T23:53:30", "url": "https://files.pythonhosted.org/packages/ef/7f/6ea8966f73de6524a443f7d2c06e92a6527ca24488de67804f3aa50ae248/elasticmodels-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "043295ba313b5b4e99e0b45899782a8f", "sha256": "c1e0e6a66b0a3908e49641259a63bf92baa9582909ee3b5509ed9cdfd9a94f81" }, "downloads": -1, "filename": "elasticmodels-0.0.10.tar.gz", "has_sig": false, "md5_digest": "043295ba313b5b4e99e0b45899782a8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6112, "upload_time": "2015-01-29T21:32:16", "url": "https://files.pythonhosted.org/packages/c8/03/988c7669e84266cb4e08babc60be9fece663a30e914a333e2deb133d92c2/elasticmodels-0.0.10.tar.gz" } ] }