David542 David542 - 2 months ago 33
Python Question

How to get a list of all indexes in python-elasticsearch

How would I get a list of the names of an index in Python? Here is what I have so far:

>>> es=e.es
>>> es
<Elasticsearch([{'host': '14555f777d8097.us-east-1.aws.found.io', 'port': 9200}])>
>>> es.indices
<elasticsearch.client.indices.IndicesClient object at 0x10de86790>
# how to get a list of all indexes in this cluster?

Answer

Here is one way to do it with the get_aliases() method:

>>> indices=es.indices.get_aliases().keys()
>>> sorted(indices)
[u'avails', u'hey', u'kibana-int']
Comments