Java API access current aliases


(Sebastian Gavarini) #1

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.


(Shay Banon) #2

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 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.


(Shay Banon) #3

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.comwrote:

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 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.


(system) #4