Unable to create indice with correct number of shard and replica

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

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?.

Hi Bernt,

I tried to remove quotes, and the result is the same, every indices has been created without 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

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

1 Like

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

1 Like

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