# Get list of aliases pointing to given index

**URL:** https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475
**Category:** Elasticsearch
**Created:** [September 5, 2013, 1:09pm UTC](https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475 "2013-09-05T13:09:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Hanish\_Bansal](https://avatars.discourse-cdn.com/v4/letter/h/e36b37/32.png) [@Hanish\_Bansal](https://discuss.elastic.co/u/Hanish_Bansal)
#### Post date: [September 5, 2013, 1:09pm UTC](https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475/1 "2013-09-05T13:09:09Z")

</div>

Hi All,

I am trying to get the list of all aliases pointing to given index.

Please suggest Java API for the same.

--  
_Thanks & Regards_  
_Hanish Bansal_

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [September 5, 2013, 6:16pm UTC](https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475/2 "2013-09-05T18:16:22Z")

</div>

You can retrieve the list of aliases for an index from the cluster state.  
There is a REST call to achieve the aliases, which does nothing more than  
retrieve the cluster state and filter by index name. Look at  
the RestGetIndicesAliasesAction class as an example. I usually would  
suggest to look for a test, but I could not find a suitable test class.

[http://IP:9200/indexname/\_alias/](http://IP:9200/indexname/_alias/)\*[http://srch-dv109:9200/products-20130831-082113/\_alias/\*](http://srch-dv109:9200/products-20130831-082113/_alias/*)

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Cheers,

Ivan

On Thu, Sep 5, 2013 at 6:09 AM, Hanish Bansal \<  
[hanish.bansal.agarwal@gmail.com](mailto:hanish.bansal.agarwal@gmail.com)\> wrote:

> Hi All,
> 
> I am trying to get the list of all aliases pointing to given index.
> 
> Please suggest Java API for the same.
> 
> --  
> _Thanks & Regards_  
> _Hanish Bansal_
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Hanish\_Bansal](https://avatars.discourse-cdn.com/v4/letter/h/e36b37/32.png) [@Hanish\_Bansal](https://discuss.elastic.co/u/Hanish_Bansal)
#### Post date: [September 6, 2013, 5:18am UTC](https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475/3 "2013-09-06T05:18:08Z")

</div>

Thanks lvan

I am able to get aliases by looking at RestGetIndicesAliasesAction class.

Java API for the same is:

ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()  
.filterRoutingTable(true)  
.filterNodes(true)  
.filteredIndices(indexName);  
Set setAliases=  
client.admin().cluster().state(clusterStateRequest).actionGet().getState().getMetaData().aliases().keySet();

On Thu, Sep 5, 2013 at 11:46 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> You can retrieve the list of aliases for an index from the cluster state.  
> There is a REST call to achieve the aliases, which does nothing more than  
> retrieve the cluster state and filter by index name. Look at  
> the RestGetIndicesAliasesAction class as an example. I usually would  
> suggest to look for a test, but I could not find a suitable test class.
> 
> [http://IP:9200/indexname/\_alias/](http://IP:9200/indexname/_alias/)\*[http://srch-dv109:9200/products-20130831-082113/\_alias/\*](http://srch-dv109:9200/products-20130831-082113/_alias/*)
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/)
> 
> Cheers,
> 
> Ivan
> 
> On Thu, Sep 5, 2013 at 6:09 AM, Hanish Bansal \<  
> [hanish.bansal.agarwal@gmail.com](mailto:hanish.bansal.agarwal@gmail.com)\> wrote:
> 
> > Hi All,
> > 
> > I am trying to get the list of all aliases pointing to given index.
> > 
> > Please suggest Java API for the same.
> > 
> > --  
> > _Thanks & Regards_  
> > _Hanish Bansal_
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
_Thanks & Regards_  
_Hanish Bansal_

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:17am UTC](https://discuss.elastic.co/t/get-list-of-aliases-pointing-to-given-index/13475/4 "2017-07-06T02:17:54Z")

</div>


