Creating DataFrame from ElasticSearch Results
Better yet, you can use the fantastic pandasticsearch
library:
from elasticsearch import Elasticsearch
es = Elasticsearch('http://localhost:9200')
result_dict = es.search(index="recruit", body={"query": {"match_all": {}}})
from pandasticsearch import Select
pandas_df = Select.from_dict(result_dict).to_pandas()
Or you could use the json_normalize function of pandas :
from pandas import json_normalize
# from pandas.io.json import json_normalize
df = json_normalize(res['hits']['hits'])
And then filtering the result dataframe by column names