# Different indexes with different number of shards

**URL:** https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790
**Category:** Elasticsearch
**Created:** [March 23, 2017, 5:59pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790 "2017-03-23T17:59:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ESCoder](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@ESCoder](https://discuss.elastic.co/u/ESCoder)
#### Post date: [March 23, 2017, 5:59pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/1 "2017-03-23T17:59:36Z")

</div>

Hi,

Can we have different indexes with different number of shards within the same setup? like index1 with 5 shards, index2 with 3 shards etc ?

On a separate note, can a node have different shards from different indexes living on it?  
for example  
node1 having index1shard1, indes2sshard1 and  
node2 having index1sshard2, index2shard2?

Thanks

---

<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: [March 23, 2017, 7:42pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/2 "2017-03-23T19:42:17Z")

</div>

Yes, that is certainly possibly and quite common. Shards will be distributed across nodes, so could end up like you describe.

---

<div class="post-metadata">

### Author: ![ESCoder](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@ESCoder](https://discuss.elastic.co/u/ESCoder)
#### Post date: [March 23, 2017, 7:44pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/3 "2017-03-23T19:44:57Z")

</div>

thanks @Christian_Dahlqvist

any idea about for my first question....about different number of shards?

---

<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: [March 23, 2017, 9:40pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/4 "2017-03-23T21:40:50Z")

</div>

That is what is possible and quite common.

---

<div class="post-metadata">

### Author: ![olcbean](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olcbean/32/19448_2.png) [@olcbean](https://discuss.elastic.co/u/olcbean)
#### Post date: [March 24, 2017, 12:05pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/5 "2017-03-24T12:05:08Z")

</div>

You can specify the number of shards when the index is created. The number of shard per index cannot be changes later on, the number of replicas can.

Please refer to [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)

---

<div class="post-metadata">

### Author: ![ESCoder](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@ESCoder](https://discuss.elastic.co/u/ESCoder)
#### Post date: [March 24, 2017, 2:58pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/6 "2017-03-24T14:58:03Z")

</div>

thank you for your response @olcbean

let me rephrase my question ......can I create an index index1 with 5 shards and index2 with 3 shards within the same setup?

---

<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: [March 24, 2017, 4:23pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/7 "2017-03-24T16:23:38Z")

</div>

Yes.

---

<div class="post-metadata">

### Author: ![olcbean](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olcbean/32/19448_2.png) [@olcbean](https://discuss.elastic.co/u/olcbean)
#### Post date: [March 25, 2017, 12:24pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/8 "2017-03-25T12:24:54Z")

</div>

```
PUT test
{
    "settings" : {
        "index" : {
            "number_of_shards" : 4, 
            "number_of_replicas" : 2 
        }
    }
}

```

creates the index `test` with 4 shards and 2 replicas. These settings are only for the index `test` and no other index. Any index created without explicitly specifying the `number_of_shards` will have 5 shards and the default `number_of_replicas` is 1.

For your concrete question :

```
PUT index1
{
    "settings" : {
        "index" : {
            "number_of_shards" : 5
        }
    }
}

```

The above can be omitted as the default `number_of_shards` is 5.

```
PUT index2
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3
        }
    }
}
```

---

<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: [April 22, 2017, 12:24pm UTC](https://discuss.elastic.co/t/different-indexes-with-different-number-of-shards/79790/9 "2017-04-22T12:24:59Z")

</div>

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