# How to modify multiple index names in Elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664>\
**Category:** Elasticsearch\
**Created:** [June 22, 2021, 2:18pm UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664 "2021-06-22T14:18:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [June 22, 2021, 2:18pm UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/1 "2021-06-22T14:18:27Z")

</div>

I have indices like below,

```auto
europe_serbia_people
europe_germany_people

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;

```auto
europe_serbia_people_old
europe_germany_people_old

```

How can i achieve the expected results ?

Thanks for answering

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [June 22, 2021, 3:12pm UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/2 "2021-06-22T15:12:21Z")

</div>

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.

[https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html)

---

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [June 23, 2021, 5:51am UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/3 "2021-06-23T05:51:09Z")

</div>

> [@elasticforme](#):
>
> which is not same as renaming. this process is fast because it links block to new index name.

I have checked the link;

I have seen the below command :

```auto
POST / my_source_index / _clone / my_target_index 

```

But my expectation is like below

```auto
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

---

<div class="post-metadata">

**Author:** ![Malaba](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Malaba](https://discuss.elastic.co/u/Malaba)\
**Post date:** [June 23, 2021, 8:05am UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/4 "2021-06-23T08:05:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [June 23, 2021, 8:39am UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/5 "2021-06-23T08:39:48Z")

</div>

I have found the solution.[stackoverflow](https://stackoverflow.com/questions/68094204/how-to-modify-multiple-index-names-in-elasticsearch/68094320?noredirect=1#comment120352909_68094320)

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

```

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [June 23, 2021, 1:29pm UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/6 "2021-06-23T13:29:22Z")

</div>

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

---

<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 21, 2021, 1:29pm UTC](https://discuss.elastic.co/t/how-to-modify-multiple-index-names-in-elasticsearch/276664/7 "2021-07-21T13:29:58Z")

</div>

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