Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch Marvel. Primary & Replicas Shards

With the newly released Marvel from ElasticSearch I wanted to ask the question whether we could adjust the amount of replicas it creates upon creating an index, that is every time it creates an index. It currently creates one primary and one replica shard. Can this be adjusted permanently?

Thanks

Update for Replicas

curl -XPUT localhost:9200/_template/marvel_custom -d '
{
    "order" : 1,
    "template" : ".marvel*",
    "settings" : {
        "number_of_replicas" : 0
    }
}'
like image 933
Nathan Smith Avatar asked Jan 30 '14 10:01

Nathan Smith


2 Answers

Elasticsearch Marvel by default indexes data into daily indices, similarly to what logstash does. It first submits an index template that contains the default settings and mappings for its indices, as mentioned here. You can see the default index template just retrieving it by id:

curl -XGET localhost:9200/_template/marvel

and you can definitely change it by just submitting an updated version of it with same name, but make sure you don't change the default mappings or anything else.

In fact instead of changing the default index template, I'd suggest to add an additional one, with order higher than 0, which applies only your custom settings:

curl -XPUT localhost:9200/_template/marvel_custom -d '
{
    "order" : 1,
    "template" : ".marvel*",
    "settings" : {
        "number_of_shards" : 5
    }
}
'

This way both templates will get applied, and the one with highest order will win when it comes to settings with same name.

like image 178
javanna Avatar answered Nov 02 '22 14:11

javanna


shouldn't new template include index.number_of_replicas 0? It seems that if it is not specified then it will fall back to default which is one

curl -XPUT localhost:9200/_template/marvel_custom
{
    "order" : 1,
    "template" : ".marvel*",
    "settings" : {
        "number_of_shards" : "5",
        "index.number_of_replicas" : "0"
    }
}
like image 1
Anton Kokarski Avatar answered Nov 02 '22 13:11

Anton Kokarski