# Elasticsearch - Forcemerge to merge several shards

**URL:** https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310
**Category:** Elasticsearch
**Created:** [April 6, 2021, 9:31am UTC](https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310 "2021-04-06T09:31:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Miguel\_BA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/miguel_ba/32/46926_2.png) [@Miguel\_BA](https://discuss.elastic.co/u/Miguel_BA)
#### Post date: [April 6, 2021, 9:31am UTC](https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310/1 "2021-04-06T09:31:08Z")

</div>

I have indexes that are created weekly, associated to an allias. The indexes were configured for two shards, and one replica per shard. The shards are very low space, around 50 mb, so I think those could be converted to one shard, to have more shards free and not exceed the recommended shard per RAM limit. For this I am using the api forcemerge, to join several indexes in a single shard. Even so, after performing the forcemerge, I still get the indexes in two shards. How can I join in a single shard the indexes that I select?

> **[Force merge API | Elasticsearch Guide \[7.12\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html)**

```auto
POST /my-index-000001,my-index-000002/_forcemerge

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 6, 2021, 10:04am UTC](https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310/2 "2021-04-06T10:04:32Z")

</div>

`_forcemerge` is used to merge segments within a shard.  
To "merge" shards, you need to use the `_shrink` API.  
See [Shrink index API | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html)

---

<div class="post-metadata">

### Author: ![Miguel\_BA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/miguel_ba/32/46926_2.png) [@Miguel\_BA](https://discuss.elastic.co/u/Miguel_BA)
#### Post date: [April 6, 2021, 3:40pm UTC](https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310/3 "2021-04-06T15:40:48Z")

</div>

Finally I used [Reindex API | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)  
With this api I group the indexes organized by weeks in months, and I assign them in their configuration a single shard and r  
Then I delete the old indexes  
Thank you

---

<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: [May 4, 2021, 3:41pm UTC](https://discuss.elastic.co/t/elasticsearch-forcemerge-to-merge-several-shards/269310/4 "2021-05-04T15:41:46Z")

</div>

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