{ "info": { "author": "Dmitri Vasilishin", "author_email": "vasilishin.d.o@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "# Elasticsearch Partition\n[![image](https://img.shields.io/pypi/v/elasticsearch-partition.svg)](https://pypi.python.org/pypi/elasticsearch-partition)\n[![Build Status](https://travis-ci.com/dmvass/elasticsearch-partition.svg?branch=master)](https://travis-ci.com/kandziu/elasticsearch-partition)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dmvass/elasticsearch-partition/blob/master/LICENSE)\n\nA Python library is written on Cython for creating Elasticsearch indexes by\ndate range.\n\nFor time oriented data, such as logs, a common strategy is to partition data\ninto indexes that hold data for a certain time range. For example, the index\n`logstash-2018.01.01` holds data for events that happened on `2018-01-01`, i.e.\na time range of a day. You can of course choose bigger or smaller time ranges\nas well(`year`, `month` or `day` frequencies), depending on your needs. Using\nindex templates, you can easily manage settings and mappings for any index\ncreated with a name starting with e.g. `logstash-*`.\n\n## Installation\nInstall the elasticsearch partition package with pip:\n```\npip install elasticsearch-partition\n```\n\n## How to Use\n### Basic usage\nHow to import and use partition module with `since` and `until` dates:\n```python\nimport datetime\nfrom elasticsearch_partition import partition\n\npartition('logs-*', datetime.date(2016, 11, 29), datetime.date(2018, 2, 4))\n# ['logs-2016-11-29', 'logs-2016-11-30', 'logs-2016-12-*', 'logs-2017-*',\n# 'logs-2018-01-*', 'logs-2018-02-01', 'logs-2018-02-02', 'logs-2018-02-03',\n# 'logs-2018-02-04']\n```\n\nWhen you are using `partition` only with `since` date, `until` will be replaced\non a current date.\n```python\npartition('logs-*', since=datetime.date(2018, 7, 10))\n# ['logs-2018-07-10', 'logs-2018-07-11', 'logs-2018-07-12', 'logs-2018-07-13',\n# 'logs-2018-07-14', 'logs-2018-07-15', 'logs-2018-07-16', 'logs-2018-07-17']\n```\n\nOr when you are using `partition` only with `until` all dates from `until` to\ncurrent date will be excluded.\n```python\npartition('logs-*', until=datetime.date(2018, 7, 10))\n# ['-logs-2018-07-10', '-logs-2018-07-11', '-logs-2018-07-12',\n# '-logs-2018-07-13', '-logs-2018-07-14', '-logs-2018-07-15',\n# '-logs-2018-07-16', '-logs-2018-07-17', 'logs-*']\n```\n\n> Note: If `until` more then current date you will get an error.\n\n### How to customize partitioning\nIf you want to change some `partition` bahavior you can do it ease with\n`RangePartition` and `formatters` module, also you can use your custom date\n`now` functions.\n```python\nfrom elasticsearch_partition import RangePartition\nfrom elasticsearch_partition.partitioning import MONTH\nfrom elasticsearch_partition.formatters import LittleEndianDateFormatter\n\n# frequency - Index partitioning frequency\n# formatter - Formatter instance\n# escape - Special character which will be replaced on a date\n# now_func - Get now date function\nmy_partition = RangePartition(\n frequency=MONTH,\n formatter=LittleEndianDateFormatter(sep='.'),\n escape='@',\n now_func=custom_date_now,\n)\n\nmy_partition('logs-@', datetime.date(2016, 11, 29), datetime.date(2018, 2, 4))\n# ['logs-11.2016', 'logs-12.2016', 'logs-*.2017', 'logs-01.2018', 'logs-02.2018']\n```\n\n### How to create custom date formatter\nAll date formatters must be inherited from abstract `DateFormatter` class and\nimplement `fmt_year`, `fmt_month` and `fmt_day` methods. Some method accept\nadditional keyword parameter `wildcard` which used for creating formatted date\nwith specified wildcard character. For example `2018-04` will be replced on\n`2018-04-*`, `2018` on `2018-*` etc.\n```python\nclass MyDateFormatter(DateFormatter):\n def fmt_year(self, year, wildcard):\n # Should be implemented\n\n def fmt_month(self, year, month, wildcard):\n # Should be implemented\n\n def fmt_day(self, year, month, day):\n # Should be implemented\n\npartition = RangePartition(formatter=MyDateFormatter())\n```\n\n### How to use with [elasticsearch-py](https://github.com/elastic/elasticsearch-py)\nThis is useful for all Elasticsearch APIs that refer to an index parameter\nsupport execution across multiple indices.\n```python\nfrom elasticsearch import Elasticsearch\n\nes = Elasticsearch()\nindexes = partition(\n 'logs-*',\n datetime.date(2016, 11, 29),\n datetime.date(2018, 2, 4)\n)\nres = es.search(index=indexes, body={\"query\": {\"match_all\": {}}})\n```\n\n### How to use with [elasticsearch-dsl-py](https://github.com/elastic/elasticsearch-dsl-py)\nThis is useful for all Elasticsearch APIs that refer to an index parameter\nsupport execution across multiple indices and similar for simple Search and\nPersistance DSL.\n```python\nfrom elasticsearch import Elasticsearch\nfrom elasticsearch_dsl import Search\n\nclient = Elasticsearch()\n\nindexes = partition(\n 'logs-*',\n datetime.date(2016, 11, 29),\n datetime.date(2018, 2, 4)\n)\nsearch = Search(using=client, index=indexes) \\\n .filter(\"term\", category=\"search\") \\\n .query(\"match\", title=\"python\") \\\n .exclude(\"match\", description=\"beta\")\n\nresponse = search.execute()\n```\n\n## Changes\nA full changelog is maintained in the [CAHNGELOG](https://github.com/dmvass/elasticsearch-partition/blob/master/CHANGELOG.md) file.\n\n## Contributing \n**elasticsearch-partition** is an open source project and contributions are\nwelcome! Check out the [Issues](https://github.com/dmvass/elasticsearch-partition/issues)\npage to see if your idea for a contribution has already been mentioned, and feel\nfree to raise an issue or submit a pull request.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dmvass/elasticsearch-partition", "keywords": "elasticsearch,partition,cython,bigdata", "license": "", "maintainer": "", "maintainer_email": "", "name": "elasticsearch-partition", "package_url": "https://pypi.org/project/elasticsearch-partition/", "platform": "", "project_url": "https://pypi.org/project/elasticsearch-partition/", "project_urls": { "Homepage": "https://github.com/dmvass/elasticsearch-partition" }, "release_url": "https://pypi.org/project/elasticsearch-partition/2.0.0/", "requires_dist": [ "cython", "tox; extra == 'dev'", "bumpversion; extra == 'dev'" ], "requires_python": "", "summary": "A Python library for creating Elasticsearch partitioned indexes by date range", "version": "2.0.0" }, "last_serial": 4973186, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "8602938698d2ec55915f82ece4595c03", "sha256": "ead0169f15603075d3bf3834aec56fda718802d9c8dc64572f7bfd5bd30ca4b7" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8602938698d2ec55915f82ece4595c03", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3744, "upload_time": "2018-07-17T20:15:26", "url": "https://files.pythonhosted.org/packages/71/64/b33116619fdd50026f712c43aa38cd696894c59ed4835acc2f87167b2725/elasticsearch_partition-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1571c575e56b5830f03acc8588e963ad", "sha256": "3ddba2779196b2f42c334d4bf50f2a087b835836a62dee69899952a40730cd96" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1571c575e56b5830f03acc8588e963ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9277, "upload_time": "2018-07-17T20:15:27", "url": "https://files.pythonhosted.org/packages/84/90/fcd998f46b9ffc06cdc1c4e2bf04058e101d27c90ba07af68b80d6bd89da/elasticsearch_partition-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "0958059a4910ca370203bb37aee8a73a", "sha256": "4a84977c166af8032b829f1d2ffa9bd78dfa4addc110a4729c28252a39561454" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0958059a4910ca370203bb37aee8a73a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3808, "upload_time": "2018-07-19T08:58:05", "url": "https://files.pythonhosted.org/packages/88/3e/c50641b6dc6e6cb92defee70c7aa5aaf021e5a06629056321ab79f59786e/elasticsearch_partition-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f2f6f47592a6529fca18f5570e9bd8c3", "sha256": "a5662520e1105a23cf28b6a8bc29a0be1f1d60512b1b6576e6a6c29595c52b47" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f2f6f47592a6529fca18f5570e9bd8c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9415, "upload_time": "2018-07-19T08:58:07", "url": "https://files.pythonhosted.org/packages/ab/8b/6e80f9717db1e48026a6ea308604a116d8426e6297b44f2dfd57ffe77525/elasticsearch_partition-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "a21af9c9177988660987231c0ea80c6b", "sha256": "4b0d4d529223e88cc31972011a14b561a35f9b5f1a25f523321400fd205f3dc5" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a21af9c9177988660987231c0ea80c6b", "packagetype": "bdist_wheel", "python_version": "3.7", "requires_python": null, "size": 10000, "upload_time": "2019-02-23T21:45:37", "url": "https://files.pythonhosted.org/packages/4d/be/8696c17d44bb2d5f129eb865491cd742eef30c82be0a5c4bb18cdf50aa64/elasticsearch_partition-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cbe164560f8ae96f1e86858c9e203f55", "sha256": "85fd32be465e928a46221b6f2718eb911784d09bd8d0748d17413787ff3f71e3" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.2.tar.gz", "has_sig": false, "md5_digest": "cbe164560f8ae96f1e86858c9e203f55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10149, "upload_time": "2019-02-23T21:45:35", "url": "https://files.pythonhosted.org/packages/b1/d1/a86a279e6ac670d937db5a0a5736c4bb3db6ddf7071e453f7034ce524aa4/elasticsearch_partition-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "54a7988d703008066b1f4f007ae670db", "sha256": "73995c67172b916ff23c3273c3ef81fa2700d27785b2accfe83b8f7d2ef4715e" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "54a7988d703008066b1f4f007ae670db", "packagetype": "bdist_wheel", "python_version": "3.7", "requires_python": null, "size": 10025, "upload_time": "2019-02-23T21:54:10", "url": "https://files.pythonhosted.org/packages/62/55/e187bded46f6dad12e4930060fa00891b93583c2264a90ca249ee134ceab/elasticsearch_partition-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c8715fc00da328a63f6b9c7f9c96e888", "sha256": "53786e25b6ce218676bdabb92836af8481a643aefce406de99a9c2b918ebc3c8" }, "downloads": -1, "filename": "elasticsearch_partition-1.0.3.tar.gz", "has_sig": false, "md5_digest": "c8715fc00da328a63f6b9c7f9c96e888", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10203, "upload_time": "2019-02-23T21:54:07", "url": "https://files.pythonhosted.org/packages/5c/86/8f04b43e4efc249d9cab29d84149ab68d85077cc149d4b5ea685556e8ba8/elasticsearch_partition-1.0.3.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "990f9d5573d287d5f57f441ca89275cf", "sha256": "1ce136ab71cd71205ce4a24fa400aaf0f2a2bb0723ffcbb35064985fef03689b" }, "downloads": -1, "filename": "elasticsearch_partition-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "990f9d5573d287d5f57f441ca89275cf", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 213037, "upload_time": "2019-03-22T14:55:15", "url": "https://files.pythonhosted.org/packages/a5/a7/1b2cc1a58c2f86c1c1f71b2ce4aea4a3f0e4bef86cadf9eec743d805d528/elasticsearch_partition-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "2560a9620b57a8180b4b4109776f7ad0", "sha256": "35cf55df7858559a1c5ce316ee4b0d9a41f088136a13f635b165575300c5391c" }, "downloads": -1, "filename": "elasticsearch_partition-2.0.0.tar.gz", "has_sig": false, "md5_digest": "2560a9620b57a8180b4b4109776f7ad0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 130902, "upload_time": "2019-03-22T14:55:18", "url": "https://files.pythonhosted.org/packages/62/9c/a2ea71c80491a0c9635c8e949174a74dc3f68a4859a717added3fc643cc7/elasticsearch_partition-2.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "990f9d5573d287d5f57f441ca89275cf", "sha256": "1ce136ab71cd71205ce4a24fa400aaf0f2a2bb0723ffcbb35064985fef03689b" }, "downloads": -1, "filename": "elasticsearch_partition-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "990f9d5573d287d5f57f441ca89275cf", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 213037, "upload_time": "2019-03-22T14:55:15", "url": "https://files.pythonhosted.org/packages/a5/a7/1b2cc1a58c2f86c1c1f71b2ce4aea4a3f0e4bef86cadf9eec743d805d528/elasticsearch_partition-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "2560a9620b57a8180b4b4109776f7ad0", "sha256": "35cf55df7858559a1c5ce316ee4b0d9a41f088136a13f635b165575300c5391c" }, "downloads": -1, "filename": "elasticsearch_partition-2.0.0.tar.gz", "has_sig": false, "md5_digest": "2560a9620b57a8180b4b4109776f7ad0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 130902, "upload_time": "2019-03-22T14:55:18", "url": "https://files.pythonhosted.org/packages/62/9c/a2ea71c80491a0c9635c8e949174a74dc3f68a4859a717added3fc643cc7/elasticsearch_partition-2.0.0.tar.gz" } ] }