Elasticsearch: Reassigning aliases to the newly created indexes using Aliases API (Java Client)

Created on 22 Nov 2012  路  2Comments  路  Source: elastic/elasticsearch

Hi folks,
my question is about reassigning an alias to the newly created index in one step.
It means, i don't want to first remove alias and add a new one, since it is not possible to send the request encapsulated in one request. IndicesAliasesRequest doesn't offer any method like reassign() or removeAndAddAlias(). The delay between remove and add requests can cause service interruptions.
Is there any workaround to solve this ?

Most helpful comment

The alias API accept a list of add/remove actions which are executed atomically in one call. Java-wise you can do the following:

client.admin().indices().prepareAliases()
                .removeAlias("old_index", "my_alias")
                .addAlias("new_index", "my_alias")
                .execute().actionGet();

All 2 comments

The alias API accept a list of add/remove actions which are executed atomically in one call. Java-wise you can do the following:

client.admin().indices().prepareAliases()
                .removeAlias("old_index", "my_alias")
                .addAlias("new_index", "my_alias")
                .execute().actionGet();

oh thanks your reply. the issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings