# Unable to create indice with correct number of shard and replica

**URL:** https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934
**Category:** Elasticsearch
**Created:** [February 4, 2019, 10:21am UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934 "2019-02-04T10:21:45Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Loudone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loudone/32/33365_2.png) [@Loudone](https://discuss.elastic.co/u/Loudone)
#### Post date: [February 4, 2019, 10:21am UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/1 "2019-02-04T10:21:45Z")

</div>

Hello all,

I'm currently trying to set dynamic template in order to set in setting part the number of shard and number of replica

my dynamic template is set like that:

> {  
> "test\_log" : {  
> "order" : 0,  
> "version" : 1,  
> "index\_patterns" : [  
> "test\*"  
> ],  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : "3",  
> "number\_of\_replicas" : "1",  
> "refresh\_interval" : "5s"  
> }  
> },

But my indice is not created on 3 shards and 1 replica.

> health status index uuid pri rep docs.count docs.deleted store.size pri.store.size  
> green open test1 hPilneqmSqWHUuwHuyjlBg 2 0 0 0 522b 522b

> {  
> "test\_log" : {  
> "settings" : {  
> "index" : {  
> "creation\_date" : "1549275393970",  
> "number\_of\_shards" : "2",  
> "number\_of\_replicas" : "0",  
> "uuid" : "mQGqCAs1SfWWrP0H9f4YeA",  
> "version" : {  
> "created" : "6050499"  
> },  
> "provided\_name" : "test\_log"  
> }  
> }  
> }  
> }

Do you have an idea about my problem?

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: [February 4, 2019, 10:51am UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/2 "2019-02-04T10:51:15Z")

</div>

> [@Loudone](#):
>
> Do you have an idea about ma problem?

I'm not sure, but have a hunch; you've wrapped the integer values for the number of shards inside quotes which is usually reserved for text, not numbers, so my theory is that the shard setting failed to take effect.

Could you try to install a new template without the quotes around the shard numbers, e.g. with an index setting like this

```
"index" : {
   "number_of_shards" : 3,
   "number_of_replicas" : 1,
   "refresh_interval" : "5s"
}

```

Hopefully that will work better when you try to create a new test\_log index?.

---

<div class="post-metadata">

### Author: ![Loudone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loudone/32/33365_2.png) [@Loudone](https://discuss.elastic.co/u/Loudone)
#### Post date: [February 4, 2019, 11:48am UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/3 "2019-02-04T11:48:01Z")

</div>

Hi Bernt,

I tried to remove quotes, and the result is the same, every indices has been created without the good settings

---

<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: [February 4, 2019, 12:06pm UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/4 "2019-02-04T12:06:11Z")

</div>

> [@Loudone](#):
>
> I tried to remove quotes, and the result is the same, every indices has been created with the good settings

I'm sorry my theory was wrong.

Could you try to fetch the template from the cluster, to see how it got parsed and stored? That is, can you run something like this:

`curl -X GET "http://localhost:9200/_template/test_log?pretty" -s`

And verify that the template really has the correct values for number\_of\_shards and number\_of\_replicas?

If that is OK, then there must something overriding the template. Perhaps you have another template of higher order (1, 2 etc) with a matching index\_patterns?

You can list all active templates by using an asterisk:

`curl -X GET "http://localhost:9200/_template/*?pretty" -s`

---

<div class="post-metadata">

### Author: ![Loudone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loudone/32/33365_2.png) [@Loudone](https://discuss.elastic.co/u/Loudone)
#### Post date: [February 4, 2019, 2:10pm UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/5 "2019-02-04T14:10:05Z")

</div>

You're right!! Congratulation!!

I found the following template set like that:

> {  
> "index\_shards" : {  
> "order" : 0,  
> "index\_patterns" : [  
> "\*"  
> ],  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : "2",  
> "number\_of\_replicas" : "0"  
> }  
> },  
> "mappings" : { },  
> "aliases" : { }  
> }  
> }

So I delete it, And it seems working fine!!

`health status index uuid pri rep docs.count docs.deleted store.size pri.store.size`  
`green open test 7iDmPsfGRa6faWLwK0_KzQ 3 1 0 0 1.5kb 783b`

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: [February 4, 2019, 2:42pm UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/6 "2019-02-04T14:42:24Z")

</div>

> [@Loudone](#):
>
> So I delete it, And it seems working fine!!

That's great, I'm happy you solved the problem 🙂

---

<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: [March 4, 2019, 2:42pm UTC](https://discuss.elastic.co/t/unable-to-create-indice-with-correct-number-of-shard-and-replica/166934/7 "2019-03-04T14:42:24Z")

</div>

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