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,
Oringin index name: my_index_20231219
To shrink shards, it makes my index name into: new_index_20231219
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.