I need to rename several indexes in a cluster (their name must be changed, I cannot use aliases).
I saw that there are no supported ways to do that, the closest I found is to rename the directory of the index, I tried this in a cluster.
The cluster has 3 machines A
, B
and C
and the shards are replicated on each of them. I shut down elasticsearch on A
, renamed /var/lib/elasticsearch/security/nodes/0/indices/oldindexname
to /var/lib/elasticsearch/security/nodes/0/indices/newindexname
and restarted A
.
The state of the cluster was yellow and elasticsearch was doing some magic to restore a correct state. After some time I ended up with
oldindexname
being available and fully replicated (recovered fromB
andC
I guess)newindexname
being available (I can search it) but the head plugin shows that its shards are in an "Unassigned" state and that they are grayed out (not replicated)
During the recovery security.log
showed the following message:
[2015-02-20 11:02:33,461][INFO ][gateway.local.state.meta ] [A.example.com] dangled index directory name is [newindexname], state name is [oldindexname], renaming to directory name
While newindexname
is searchable, it is certainly not in a normal state.
I rolled back to the previous state by deleting newindexname
. The cluster is back to green without any "Unassigned" entries.
Given that, how can I rename oldindexname
to newindexname
in a cluster?
Note: the ultimate solution I have in mind is to scroll-copy oldindex
into newindex
and delete oldindex
afterwards. This is going to take time so if there is a more direct solution it would be great.