# Java API access current aliases

**URL:** <https://discuss.elastic.co/t/java-api-access-current-aliases/3499>\
**Category:** Elasticsearch\
**Created:** [November 1, 2010, 10:22pm UTC](https://discuss.elastic.co/t/java-api-access-current-aliases/3499 "2010-11-01T22:22:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Gavarini](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@Sebastian\_Gavarini](https://discuss.elastic.co/u/Sebastian_Gavarini)\
**Post date:** [November 1, 2010, 10:22pm UTC](https://discuss.elastic.co/t/java-api-access-current-aliases/3499/1 "2010-11-01T22:22:26Z")

</div>

Hi all,

Probably I am looking at the wrong place, but I couldn't find a way to  
get the current aliases in the Java client API. I saw add/remove in  
IndicesAliasesRequest, I also checked IndicesStatusRequest that would  
map to the \_status REST API, but no luck either.

I am trying to access the current alias assignments, because if my  
Java client application happens to get restarted for whatever reason,  
I would loose track of the assigned aliases in ES and when it's back  
up again, I need to see them to use or recreate some or all.

Could someone please hint me to a 'getAliases()' method in the Java  
API? If it isn't implemented, could I add a feature request for it?

Thanks,  
Sebastian.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 1, 2010, 10:27pm UTC](https://discuss.elastic.co/t/java-api-access-current-aliases/3499/2 "2010-11-01T22:27:50Z")

</div>

There isn't a nice API for it, but its represented as a setting, so you can  
do (on IndexStatus, which you get back from the indices status API, per  
index):

indexStatus.settings().getAsArray("index.aliases").

Open a feature request to encapsulate this in a nice getter method. It  
should be nicer.

-shay.banon

On Tue, Nov 2, 2010 at 12:22 AM, Sebastian [sgavarini@gmail.com](mailto:sgavarini@gmail.com) wrote:

> Hi all,
> 
> Probably I am looking at the wrong place, but I couldn't find a way to  
> get the current aliases in the Java client API. I saw add/remove in  
> IndicesAliasesRequest, I also checked IndicesStatusRequest that would  
> map to the \_status REST API, but no luck either.
> 
> I am trying to access the current alias assignments, because if my  
> Java client application happens to get restarted for whatever reason,  
> I would loose track of the assigned aliases in ES and when it's back  
> up again, I need to see them to use or recreate some or all.
> 
> Could someone please hint me to a 'getAliases()' method in the Java  
> API? If it isn't implemented, could I add a feature request for it?
> 
> Thanks,  
> Sebastian.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 2, 2010, 8:15am UTC](https://discuss.elastic.co/t/java-api-access-current-aliases/3499/3 "2010-11-02T08:15:47Z")

</div>

By the way, it is exposed a nice API on the IndexMetaData class, which can  
be accessed by calling the cluster state API (which is a better way to get  
it than the status API).

-shay.banon

On Tue, Nov 2, 2010 at 12:27 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> There isn't a nice API for it, but its represented as a setting, so you can  
> do (on IndexStatus, which you get back from the indices status API, per  
> index):
> 
> indexStatus.settings().getAsArray("index.aliases").
> 
> Open a feature request to encapsulate this in a nice getter method. It  
> should be nicer.
> 
> -shay.banon
> 
> On Tue, Nov 2, 2010 at 12:22 AM, Sebastian [sgavarini@gmail.com](mailto:sgavarini@gmail.com) wrote:
> 
> > Hi all,
> > 
> > Probably I am looking at the wrong place, but I couldn't find a way to  
> > get the current aliases in the Java client API. I saw add/remove in  
> > IndicesAliasesRequest, I also checked IndicesStatusRequest that would  
> > map to the \_status REST API, but no luck either.
> > 
> > I am trying to access the current alias assignments, because if my  
> > Java client application happens to get restarted for whatever reason,  
> > I would loose track of the assigned aliases in ES and when it's back  
> > up again, I need to see them to use or recreate some or all.
> > 
> > Could someone please hint me to a 'getAliases()' method in the Java  
> > API? If it isn't implemented, could I add a feature request for it?
> > 
> > Thanks,  
> > Sebastian.

---

<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, 4:17am UTC](https://discuss.elastic.co/t/java-api-access-current-aliases/3499/4 "2017-07-06T04:17:19Z")

</div>


