es get all fields

PHOTO EMBED

Thu Oct 14 2021 02:59:38 GMT+0000 (Coordinated Universal Time)

Saved by @aurora1625 #python #elasticsearch

es = Elasticsearch()
# get all indices name
indices_names = []
for elem in es.cat.indices(format="json"):
    indices_names.append( elem['index'] )
# get all fileds of index
dict_index_fields = {}
index = 'factiva.snapshot'
mapping = es.indices.get_mapping(index)
dict_index_fields[index] = []
for field in mapping[index]['mappings']['properties']:
    dict_index_fields[index].append(field)
content_copyCOPY