# How change the number of shards and replicas in Elasticsearch

**URL:** <https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736>\
**Category:** Elasticsearch\
**Created:** [May 5, 2017, 2:06pm UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736 "2017-05-05T14:06:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![emilio](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@emilio](https://discuss.elastic.co/u/emilio)\
**Post date:** [May 5, 2017, 2:06pm UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/1 "2017-05-05T14:06:35Z")

</div>

Dear all,

I need to decrease the number of shards and replicas in Elasticsearch.

I have just one node and there is no need to have more than one shard and zero replicas.

Please give me appropriate curl.

I couldn't find such API on elastic site.

Quick response will be greatly appreciated.

---

<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:** [May 5, 2017, 2:19pm UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/2 "2017-05-05T14:19:08Z")

</div>

You can't change the number of shards but you can [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-reindex.html).  
You can change [the number of replicas](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-update-settings.html).

---

<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:** [May 5, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/3 "2017-05-05T16:07:03Z")

</div>

If you are on Elasticsearch 5.x, you may also be able to use the [shrink index API](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-shrink-index.html).

---

<div class="post-metadata">

**Author:** ![emilio](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@emilio](https://discuss.elastic.co/u/emilio)\
**Post date:** [May 8, 2017, 7:39am UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/4 "2017-05-08T07:39:40Z")

</div>

Dear Christian,

How can i do that correctly?

I have indices named logs-2017.05.XX. Every index has 5 shards and 0 replica.

I need shrink it to index with 1 shard and 0 replica, because my ES server is one node.

How can i settle it properly?

Another one question. My current indices ~ 90-100GB. What will be expected size of shinked index?

Does close operation of index help to decrease size of index?

---

<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:** [May 8, 2017, 7:58am UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/5 "2017-05-08T07:58:17Z")

</div>

If your current shard size is around 20GB you may not want to reduce the number of shards per index much, if at all.

---

<div class="post-metadata">

**Author:** ![emilio](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@emilio](https://discuss.elastic.co/u/emilio)\
**Post date:** [May 8, 2017, 10:26am UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/6 "2017-05-08T10:26:41Z")

</div>

But how can i get the size of shards in indices?

And how i can optimize size of indices? Should it be done on ES or filebeat side if i have text logs not having json format, but sended using json codec of filebeat?

---

<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:** [May 9, 2017, 4:37am UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/7 "2017-05-09T04:37:22Z")

</div>

The size the data takes up in Elasticsearch once indexed depends on how the data is mapped when indexed into Elasticsearch, and can be controlled and optimised through index templates. There is [a blog post](https://www.elastic.co/blog/elasticsearch-storage-the-true-story-2.0) that discussed this, and even though it is a bit old most of it is still valid.

---

<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:** [June 6, 2017, 4:49am UTC](https://discuss.elastic.co/t/how-change-the-number-of-shards-and-replicas-in-elasticsearch/84736/8 "2017-06-06T04:49:33Z")

</div>

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