How to modify multiple index names in Elasticsearch

I have indices like below,


etc. (I have a lot of indices)

I want to change all indices with putting "old" keyword to end of indices.

I mean the indices that starts with europe should ends with "old"

I have checked _reindex api but I don't want to merge my indices , and i can't call this api one by one for all indices cause i have a lot of it.

The expected results should be;


How can i achieve the expected results ?

Thanks for answering

elasticsearch has option to clone the index.

you froze the index first (put it in readonly) and then clone it with new name.
and then remove old one.

which is not same as renaming. this process is fast because it links block to new index name.

1 Like

I have checked the link;

I have seen the below command :

POST / my_source_index / _clone / my_target_index 

But my expectation is like below

source: europe_*
dest: europe_*_old 

In this link, I haven't seen any thing that is doing this operation. Could you share sample query that accomplish this issue?

Thank you

Hello @rknd,
I don't think you can rename all your indices at once without merging them in Elastic.
Instead, you can use "_reindex" api to create new indices one by one.
Others ways are to use Logstash or to look at Curator.

I have found the solution.stackoverflow

POST _reindex
  "source": {
    "index": "europe_*"
  "dest": {
    "index": "dummy"
  "script": {
    "lang": "painless",
    "source": "ctx._index = ctx._index + '_old'"

but this is reindex. that means it will be slow. but yes less command to run

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.