1

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.

ABCD
  • 730
  • 1
  • 13
  • 31

1 Answers1

2

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.

Amit
  • 30,756
  • 6
  • 57
  • 88
  • I want to put shard size. Number of shard is something I have already added for my purpose (1 shard is enough for me). Do you know something related to shard size? How should I add size? – ABCD Jun 04 '20 at 13:30
  • @Vivek as I mentioned at the end of my answer, this is not something which you can control :) – Amit Jun 04 '20 at 13:32
  • @Vivek if you are worried that you shard size will be huge, then you can reindex them to multiple primary shard(if time based index isn't possible) or use time-based indices. – Amit Jun 04 '20 at 13:33
  • @OpsterElasticseachNinja You are right, I meant size in GB. Thanks.. – ABCD Jun 04 '20 at 13:39
  • Does replica counts into the number of total shards? So with one replicate, it is 10 shards per index? – Raj Nov 08 '20 at 00:37
  • @LeninRajRajasekaran, you are right :), if you have 5 primary shards with 1 replication aka each primary shard will have 1 replica shard than total shards will be 10 . – Amit Nov 08 '20 at 02:05