Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 
like image 293
David542 Avatar asked Aug 10 '15 20:08

David542


People also ask

How do I list all indexes in Elasticsearch?

There are multiple ways to list all of the indexes contained in an Elasticsearch cluster. One common way of doing this is to use cURL and Kibana to issue HTTP requests to communicate with the Elasticsearch cluster to have it return all of the index names and their respective UUIDs.

Where are indexes stored in Elasticsearch?

By default, Elasticsearch indexes all data in every field and each indexed field has a dedicated, optimized data structure. For example, text fields are stored in inverted indices, and numeric and geo fields are stored in BKD trees.


2 Answers

This question comes up when searching for information on retrieving aliases using the python-elasticsearch library. The accepted answer says to use get_aliases but that method has been removed (as of 2017). To get aliases, you can use the following:

 es.indices.get_alias("*") 
like image 200
erewok Avatar answered Sep 21 '22 17:09

erewok


how to get a list of all indexes in this cluster?

Use the wildcard. Works with elasticsearch-py.

for index in es.indices.get('*'):   print index 
like image 35
pascal Avatar answered Sep 22 '22 17:09

pascal