# Get index by alias with python api

**URL:** <https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628>\
**Category:** Elasticsearch\
**Created:** [June 27, 2018, 1:18pm UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628 "2018-06-27T13:18:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrdxwandg](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@hrdxwandg](https://discuss.elastic.co/u/hrdxwandg)\
**Post date:** [June 27, 2018, 1:18pm UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/1 "2018-06-27T13:18:36Z")

</div>

how to get actual index name by index alias name with elasticsearch-py or elasticsearch-dsl-py  
the version of es is 6.2.4

for your help! thank you ahead!

---

<div class="post-metadata">

**Author:** ![hrdxwandg](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@hrdxwandg](https://discuss.elastic.co/u/hrdxwandg)\
**Post date:** [June 28, 2018, 1:51am UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/2 "2018-06-28T01:51:04Z")

</div>

up,up

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2018, 5:45am UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/3 "2018-06-28T05:45:51Z")

</div>

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

**Author:** ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)\
**Post date:** [June 28, 2018, 2:00pm UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/4 "2018-06-28T14:00:24Z")

</div>

It's easy as that:

```
if es.indices.exists_alias("test-alias"):    
     print(list(es.indices.get("test-alias").keys())[0])
```

---

<div class="post-metadata">

**Author:** ![hrdxwandg](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@hrdxwandg](https://discuss.elastic.co/u/hrdxwandg)\
**Post date:** [June 29, 2018, 1:18am UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/5 "2018-06-29T01:18:14Z")

</div>

ok,thanks

---

<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 27, 2018, 1:18am UTC](https://discuss.elastic.co/t/get-index-by-alias-with-python-api/137628/6 "2018-07-27T01:18:23Z")

</div>

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