# How do you change the default number of shards?

**URL:** <https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508>\
**Category:** Elasticsearch\
**Created:** [May 28, 2015, 6:14pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508 "2015-05-28T18:14:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [May 28, 2015, 6:14pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/1 "2015-05-28T18:14:28Z")

</div>

I'm trying to reduce my logstash shards per index down from 5 to 2. ([Due to this conversation](https://discuss.elastic.co/t/when-should-you-split-your-indexes/579))

I've downloaded my template.

```
curl -XGET $ELK/_template/logstash > logstash-template.json

```

Then I've modified the settings field.

```
"settings" : {
        "number_of_shards" : 2
    },

```

However, when I try and upload the template, I get this error

```
curl -XPUT "$ELK/_template/logstash" -d@logstash-template.json
{"error":"ActionRequestValidationException[Validation Failed: 1: template is missing;]","status":400}

```

Is this the correct way to change the default number of shards per index? If so, what does this error mean?

---

<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:** [May 28, 2015, 6:20pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/2 "2015-05-28T18:20:40Z")

</div>

The output from /\_template/logstash isn't the same as the expected format of a template when posting _to_ ES. If you look at the [index template documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) and compare it with logstash-template.json you'll note that the latter has a top-level "logstash" field that shouldn't be there. So the index template you send to ES should look like this:

```
{
  "template": "logstash-*",
  "settings": {
    "number_of_shards": 2
  },
  ...
}

```

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [May 28, 2015, 7:04pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/3 "2015-05-28T19:04:39Z")

</div>

Thanks,

So just to clarify, I should take my logstash-template.json and convert it from this:

```json
{
  "logstash" : {
    "order" : 0,
    "template" : "logstash-*",
    "settings" : {
      "number_of_shards": 2
    },
    "mappings" : {
      "_default_" : {
...

```

to this

```json
{
    "template" : "logstash-*",
    "settings" : {
      "number_of_shards": 2
    },
    "mappings" : {
      "_default_" : {

```

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [May 28, 2015, 7:18pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/4 "2015-05-28T19:18:44Z")

</div>

This appears to have worked.

I've blogged the full procedure here for posterity.

[http://spuder.github.io/elasticsearch,/logstash/elasticsearch-default-shards/](http://spuder.github.io/elasticsearch,/logstash/elasticsearch-default-shards/)

---

<div class="post-metadata">

**Author:** ![Ankit\_Singhal](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Ankit\_Singhal](https://discuss.elastic.co/u/Ankit_Singhal)\
**Post date:** [June 9, 2016, 12:42pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/5 "2016-06-09T12:42:25Z")

</div>

Above link is not working.. Please provide the updated link.

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [June 11, 2016, 12:43am UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/6 "2016-06-11T00:43:51Z")

</div>

The new link is here:

> **[Spencer Owen](http://spuder.github.io/2015/elasticsearch-default-shards/)**
>
> The art of progress is to preserve order amid change and preserve change amid order - Alfred North Whitehead

---

<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:44pm UTC](https://discuss.elastic.co/t/how-do-you-change-the-default-number-of-shards/1508/7 "2017-07-05T22:44:38Z")

</div>


