# Removing shards

**URL:** https://discuss.elastic.co/t/removing-shards/93363
**Category:** Elasticsearch
**Created:** [July 17, 2017, 9:07am UTC](https://discuss.elastic.co/t/removing-shards/93363 "2017-07-17T09:07:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![FR-TheS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fr-thes/32/17396_2.png) [@FR-TheS](https://discuss.elastic.co/u/FR-TheS)
#### Post date: [July 17, 2017, 9:07am UTC](https://discuss.elastic.co/t/removing-shards/93363/1 "2017-07-17T09:07:37Z")

</div>

Hello,

It is possible through the API to remove 3 shards to all existing index?  
Don't care if data will be lost.

Thank you.

---

<div class="post-metadata">

### Author: ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)
#### Post date: [July 17, 2017, 9:31am UTC](https://discuss.elastic.co/t/removing-shards/93363/2 "2017-07-17T09:31:28Z")

</div>

You can change the number of replicas per index dynamically but not the number of primary shards, which must be set on index creation.

To change the number of primary shards you can create a new index with the same mapping as the old but with 3 less primary shards and then use the Reindex API to copy the data from the old to the new index:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)

---

<div class="post-metadata">

### Author: ![FR-TheS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fr-thes/32/17396_2.png) [@FR-TheS](https://discuss.elastic.co/u/FR-TheS)
#### Post date: [July 17, 2017, 9:33am UTC](https://discuss.elastic.co/t/removing-shards/93363/3 "2017-07-17T09:33:21Z")

</div>

Ok, that's what I supposed.  
I will purge all index and recreate them with less shards.

Thank you :).

---

<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: [July 17, 2017, 9:33am UTC](https://discuss.elastic.co/t/removing-shards/93363/4 "2017-07-17T09:33:52Z")

</div>

If you are on Elasticsearch 5.x you can also use the shrink index API.

---

<div class="post-metadata">

### Author: ![FR-TheS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fr-thes/32/17396_2.png) [@FR-TheS](https://discuss.elastic.co/u/FR-TheS)
#### Post date: [July 17, 2017, 12:03pm UTC](https://discuss.elastic.co/t/removing-shards/93363/5 "2017-07-17T12:03:26Z")

</div>

Perfect!  
Exactly what I want 🙂

---

<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: [August 14, 2017, 12:03pm UTC](https://discuss.elastic.co/t/removing-shards/93363/6 "2017-08-14T12:03:45Z")

</div>

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