amazon-web-serviceselasticsearchaws-elasticsearchelasticsearch-template

How could I put shard size explicitly by template in AWS elasticsearch?


I am new to elasticsearch. I have only one shard with no replica, this shard gets default shard size. Now I want to add shard size explicitly by using template. But when I search for this here, it don't have any property to set shard size. Am I missing something? Is there any other way to do it? And what is default size for a shard? Below is my current template,

{
    "index_patterns": ["centralized-logging-index-*"],
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
    },
    "mappings": {
    }
}

I am using elasticsearch on AWS.


Solution

  • Default no of primary shards changed from 5 to 1 per index from ES 7.o version and above API should work when you want to change the number of shards for an index or in an index template.

    I just created an index with 5 primary shards by index API .

    Put aws-domain/myindex

    {
        "settings": {
            "number_of_shards": 5 // myindex will have 5 primary shards
         }
    }
    

    You can verify the same using the GET on above API

    GET aws-domain/myindex

    {
        "myindex": {
            "aliases": {},
            "mappings": {},
            "settings": {
                "index": {
                    "creation_date": "1591277226075",
                    "number_of_shards": "5",
                    "number_of_replicas": "1",
                    "uuid": "aKbGoSs9RhC_q5iUH6qauw",
                    "version": {
                        "created": "7040299"
                    },
                    "provided_name": "myindex"
                }
            }
        }
    }
    

    Not sure, what do you mean by shard size and if you mean size in GB or something then there is no property to set this as it is dynamic and changed based on number of docs.