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

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

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? :smiling_face_with_tear:

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 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 instead of reindexing the data, which is a lot faster.

1 Like

Thanks for helpling me.
You saved my day :smiley:

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