# elastic_helper
Two simple functions
* One used to convert an elastic search collection into a dataframe. See the code for the various parameters.
* One used to convert a dataframe into an elastic search collection
## Installation
```sh
pip install elastic-helper
```
the pypi page (https://pypi.org/project/elastic-helper/):
## Example Elastic To Pandas
### Parameters
* **es** -- The elastic connection object
* **index** -- The elastic index
* **query** -- (optional) The elastic query in lucene format Example: "module: *"
* **start** -- (optional) The time range start if any
* **end** -- (optional) The time range start if any
* **timestampfield** -- (optional) The timestamp field used by the start and stop parameters
* **datecolumns** -- (optional) A collection of columns that must be converted to dates
* **scrollsize** -- (optional) The size of the scroll to use
* **size** -- (optional) The maximum number of records to retrieve
* **_source** -- (optional) The fields to retrieve
```python
from elastic_helper import es_helper
dataframe=es_helper.elastic_to_dataframe(es,index="docker_stats*"
,_source=['read', 'cpu_percent', 'name']
,datecolumns=["read"]
,timestampfield="read"
,start=datetime.now()-timedelta(hours=1)
,end=datetime.now())
```
## Example Pandas To Elastic
* Use an **_index** column in the dataframe to specify the target index
* Use an **_id** column in the dataframe to specify the id
```python
from elastic_helper import es_helper
es_helper.dataframe_to_elastic(es,my_df)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/snuids/elastic_helper",
"name": "elastic-helper",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "ElasticSearch,pandas,convert",
"author": "snuids",
"author_email": "snuids@mannekentech.com",
"download_url": "https://files.pythonhosted.org/packages/90/5b/fe0cf2292d6e7bcc3ca0571ed550a74eef0cecd0715500890df6234a7762/elastic_helper-1.2.4.tar.gz",
"platform": null,
"description": "# elastic_helper\nTwo simple functions\n* One used to convert an elastic search collection into a dataframe. See the code for the various parameters.\n* One used to convert a dataframe into an elastic search collection\n\n\n## Installation\n\n```sh\npip install elastic-helper\n```\n\n\nthe pypi page (https://pypi.org/project/elastic-helper/):\n\n## Example Elastic To Pandas\n\n### Parameters\n\n* **es** -- The elastic connection object\n* **index** -- The elastic index\n* **query** -- (optional) The elastic query in lucene format Example: \"module: *\"\n* **start** -- (optional) The time range start if any\n* **end** -- (optional) The time range start if any\n* **timestampfield** -- (optional) The timestamp field used by the start and stop parameters\n* **datecolumns** -- (optional) A collection of columns that must be converted to dates\n* **scrollsize** -- (optional) The size of the scroll to use\n* **size** -- (optional) The maximum number of records to retrieve\n* **_source** -- (optional) The fields to retrieve\n\n```python\nfrom elastic_helper import es_helper \n\ndataframe=es_helper.elastic_to_dataframe(es,index=\"docker_stats*\"\n ,_source=['read', 'cpu_percent', 'name']\n ,datecolumns=[\"read\"]\n ,timestampfield=\"read\"\n ,start=datetime.now()-timedelta(hours=1)\n ,end=datetime.now()) \n```\n\n## Example Pandas To Elastic\n\n* Use an **_index** column in the dataframe to specify the target index\n* Use an **_id** column in the dataframe to specify the id\n\n```python\nfrom elastic_helper import es_helper \n\nes_helper.dataframe_to_elastic(es,my_df) \n```",
"bugtrack_url": null,
"license": "",
"summary": "Elastic Search to Pandas Dataframe",
"version": "1.2.4",
"split_keywords": [
"elasticsearch",
"pandas",
"convert"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "905bfe0cf2292d6e7bcc3ca0571ed550a74eef0cecd0715500890df6234a7762",
"md5": "e6c1b665de800ab6c73f3326018ae655",
"sha256": "3da2fd79c1ecfb4d9587e4ba214423a32218575f940249a2a6e9e40d70774c64"
},
"downloads": -1,
"filename": "elastic_helper-1.2.4.tar.gz",
"has_sig": false,
"md5_digest": "e6c1b665de800ab6c73f3326018ae655",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5634,
"upload_time": "2023-04-28T11:40:08",
"upload_time_iso_8601": "2023-04-28T11:40:08.497177Z",
"url": "https://files.pythonhosted.org/packages/90/5b/fe0cf2292d6e7bcc3ca0571ed550a74eef0cecd0715500890df6234a7762/elastic_helper-1.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-28 11:40:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "snuids",
"github_project": "elastic_helper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "elastic-helper"
}