# Reindex after Shrink to rename index (to the original one)?

**URL:** https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606
**Category:** Elasticsearch
**Created:** [December 19, 2023, 2:07am UTC](https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606 "2023-12-19T02:07:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![HyebinHong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hyebinhong/32/122465_2.png) [@HyebinHong](https://discuss.elastic.co/u/HyebinHong)
#### Post date: [December 19, 2023, 2:07am UTC](https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606/1 "2023-12-19T02:07:29Z")

</div>

Hello, Elastic!

According to my former question, I realized I need to change my settings related to shards and replicas. (Huge thanks to @Christian_Dahlqvist )  
[Here is my former question](https://discuss.elastic.co/t/validation-failed-1-this-action-would-add-8-total-shards-but-this-cluster-currently-has-3997-4000-maximum-shards-open/349527)

Reducing replica was easy with `PUT /{index}/_settings`, however, I've noticed that to decrease shards I need to use Shirink API. And it needs new index name (e.g. target\_index). When I have to use my former index name for the reason like naming patterns etc, do I need to delete an old index then reindex a new one to rename it?

I mean,

1. Oringin index name: my\_index\_20231219
2. To shrink shards, it makes my index name into: new\_index\_20231219
3. Reindex to renmae it: my\_index\_20231219

Aside from alias settings, is it the only way? 🥲

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [December 19, 2023, 6:23am UTC](https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606/2 "2023-12-19T06:23:19Z")

</div>

The first step I would recommend you do is to change your index template to have 1 primary shard and 1 replica shard per index. This will apply to all new indices and help keep the count down over time.

The second step is to use the [update index settings API](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-update-settings.html) to set the number of replicas to 1 for all existing indices. As you currently have 3 replicas configured this alone will drop the shard count by 50%.

These 2 steps may be sufficient if your retention period means that you will no longer hit the limit, and you may not need to shrink the existing indices but rather just wait for them to age out.

If you still need to shrink the existing indices, it may make sense to select a new index name that still matches your index pattern, e.g. `my_index_new_20231219` instead of `new_index_20231219`, as that may allow you to not require reindexing or use of a large number of aliases. If you are on a reasonably recent version you can also use the [clone index API](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-clone-index.html) instead of reindexing the data, which is a lot faster.

---

<div class="post-metadata">

### Author: ![HyebinHong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hyebinhong/32/122465_2.png) [@HyebinHong](https://discuss.elastic.co/u/HyebinHong)
#### Post date: [December 19, 2023, 11:45pm UTC](https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606/3 "2023-12-19T23:45:23Z")

</div>

Thanks for helpling me.  
You saved my day 😃

---

<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: [January 16, 2024, 11:45pm UTC](https://discuss.elastic.co/t/reindex-after-shrink-to-rename-index-to-the-original-one/349606/4 "2024-01-16T23:45:45Z")

</div>

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