# Get Index name based on Aliases

**URL:** <https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793>\
**Category:** Elasticsearch\
**Created:** [February 14, 2018, 12:32pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793 "2018-02-14T12:32:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akib\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Akib\_Ali](https://discuss.elastic.co/u/Akib_Ali)\
**Post date:** [February 14, 2018, 12:32pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/1 "2018-02-14T12:32:10Z")

</div>

I have index which has multiple aliases names. And now i want to get all the index names which contain some given aliases names.  
Example:  
Index\_name: test  
Aliases name: a1,a2,a3

Index\_name: test2  
Aliases name: a1,a3

Index\_name: test3  
Aliases name: a1

Now i want to get all the index names which has a1,a2,a3 in its alias names.  
expected from above example: test

Could someone please help me with the API/Query.

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [February 14, 2018, 12:47pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/2 "2018-02-14T12:47:04Z")

</div>

Depending on what you have named your aliases opposed to the examples shared of a1, a2, a3.  
`GET _alias/a*` will return you something alike:

```auto
{
  "test1": {
    "aliases": {
      "alias1": {},
      "alias2": {},
      "alias3": {}
    }
  },
  "test3": {
    "aliases": {
      "alias1": {}
    }
  },
  "test2": {
    "aliases": {
      "alias1": {},
      "alias3": {}
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Akib\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Akib\_Ali](https://discuss.elastic.co/u/Akib_Ali)\
**Post date:** [February 14, 2018, 12:51pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/3 "2018-02-14T12:51:12Z")

</div>

Thanks @JKhondhu But this API gives me all the index names. I want to get only that index name which has all the aliases names in it. Like in above example i only want "test" index name as it contains all the three aliases a1,a2,a3.

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [February 14, 2018, 1:01pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/5 "2018-02-14T13:01:08Z")

</div>

Okay, if your aliases are named such as a1, a2, a3, then this will not help.  
Perhaps get alias pertaining to index names?  
`GET test1,test2,test3/_alias`

---

<div class="post-metadata">

**Author:** ![Akib\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Akib\_Ali](https://discuss.elastic.co/u/Akib_Ali)\
**Post date:** [February 14, 2018, 1:07pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/6 "2018-02-14T13:07:07Z")

</div>

@JKhondhu I do not have index names with me at the time of searching. I get multiple aliases now i want to get the index name which contains all the aliases.(AND operator)

---

<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:** [March 14, 2018, 1:07pm UTC](https://discuss.elastic.co/t/get-index-name-based-on-aliases/119793/7 "2018-03-14T13:07:30Z")

</div>

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