# Query for all indices in a cluster

**URL:** https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481
**Category:** Elasticsearch
**Created:** [June 26, 2018, 5:34pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481 "2018-06-26T17:34:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![TwoDragon](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TwoDragon](https://discuss.elastic.co/u/TwoDragon)
#### Post date: [June 26, 2018, 5:34pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481/1 "2018-06-26T17:34:40Z")

</div>

Hi,  
In Elasticsearch 6.x, there is a call to es.indices.get\_alias to get all the indices in a given alias. Is there a method to get all indices that are not associated with any alias. My purpose is to clean up those indices that are not associated with any alias.  
Thanks,

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [June 26, 2018, 7:10pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481/2 "2018-06-26T19:10:49Z")

</div>

Not that I'm aware of. You can get a list of _all_ the indices ([Cat Indices](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html), [Get Index](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html), etc), but I can't think of an API that returns only the indices that don't have an associated alias.

I think you'll have to get the list of indices, then the list of aliases and their associated indices, and intersect the two sets client-side.

---

<div class="post-metadata">

### Author: ![TwoDragon](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TwoDragon](https://discuss.elastic.co/u/TwoDragon)
#### Post date: [June 26, 2018, 7:17pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481/3 "2018-06-26T19:17:39Z")

</div>

Thanks, I can use curl to get the indices as you suggested. Does it have any way to get indices that match a certain pattern in Python?

curl -X GET "localhost:9200/1234\*"

---

<div class="post-metadata">

### Author: ![TwoDragon](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TwoDragon](https://discuss.elastic.co/u/TwoDragon)
#### Post date: [June 26, 2018, 9:08pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481/4 "2018-06-26T21:08:01Z")

</div>

I found out that you can get all the indices that match a pattern as  
es.indices.get(index="1234\*")

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 24, 2018, 9:08pm UTC](https://discuss.elastic.co/t/query-for-all-indices-in-a-cluster/137481/5 "2018-07-24T21:08:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
