ElasticSearch — Convert your index data into Pandas DataFrame
Sep 2, 2018 · 1 min read
If you work with Pandas and use elasticsearch, chances are you may have a requirement to convert your index data into a Pandas Dataframe.
This article explains how you can do that in 5 lines of code.
Before you begin, you need to have the following libraries installed in your environment.
#code you will need to write:
from elasticsearch import Elasticsearch
from pandasticsearch import Select
# Connection to ElasticSearch
es = Elasticsearch([‘http://localhost:9200'],timeout=600)
# Retrieving all documents in index (no query given)
documents = es.search(index=’myindex’,body={})
# Convert the result to Pandas Dataframe
pandas_df = Select.from_dict(documents).to_pandas()
