# Set replica shard to default 0

**URL:** https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170
**Category:** Elasticsearch
**Created:** [July 11, 2016, 9:02am UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170 "2016-07-11T09:02:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gringo](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@gringo](https://discuss.elastic.co/u/gringo)
#### Post date: [July 11, 2016, 9:02am UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170/1 "2016-07-11T09:02:59Z")

</div>

Is there any way to set the replica shard such that it will always be 0 when a new index is created?

The default that I am getting now is that logstash output will result the 5 primary and 5 replica shards in my 2 nodes. I want 5 primary shard only and have it spread across the two nodes.

I am doing so to save disk usage.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 11, 2016, 9:40am UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170/2 "2016-07-11T09:40:27Z")

</div>

You can set the default number of shards and replicas for new indexes via elasticsearch.yml. You can also, which I recommend, use index templates to accomplish the same thing.

You should probably reduce the number of shards too. If you have daily rolling indexes you don't need five shards if you have a two-node cluster.

---

<div class="post-metadata">

### Author: ![gringo](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@gringo](https://discuss.elastic.co/u/gringo)
#### Post date: [July 11, 2016, 9:45am UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170/3 "2016-07-11T09:45:32Z")

</div>

Due to limited hardware I am now running 2 nodes. I intend to put in more more nodes in the future. My index size ranges from 1 to 2 GB. This is why I am using the default 5 shard config so that if it grows in the future I can still support a maximum of 5 GB per index.

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [July 11, 2016, 3:05pm UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170/4 "2016-07-11T15:05:22Z")

</div>

Agreeing that index templates is the better way to do this. It'll be more flexible, and you can tweak it over time without restarting the nodes. You can basically setup a catchall pattern that matches all new indices:

```auto
PUT /_template/everything_template
{
  "template": "*",
  "settings": {
    "number_of_replicas": 0
  }
}

```

Index template docs here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)

---

<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: [July 5, 2017, 10:36pm UTC](https://discuss.elastic.co/t/set-replica-shard-to-default-0/55170/5 "2017-07-05T22:36:33Z")

</div>


