Different indexes with different number of shards

Hi,

Can we have different indexes with different number of shards within the same setup? like index1 with 5 shards, index2 with 3 shards etc ?

On a separate note, can a node have different shards from different indexes living on it?
for example
node1 having index1shard1, indes2sshard1 and
node2 having index1sshard2, index2shard2?

Thanks

Yes, that is certainly possibly and quite common. Shards will be distributed across nodes, so could end up like you describe.

thanks @Christian_Dahlqvist

any idea about for my first question....about different number of shards?

That is what is possible and quite common.

You can specify the number of shards when the index is created. The number of shard per index cannot be changes later on, the number of replicas can.

Please refer to https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

thank you for your response @olcbean

let me rephrase my question ......can I create an index index1 with 5 shards and index2 with 3 shards within the same setup?

Yes.

PUT test
{
    "settings" : {
        "index" : {
            "number_of_shards" : 4, 
            "number_of_replicas" : 2 
        }
    }
}

creates the index test with 4 shards and 2 replicas. These settings are only for the index test and no other index. Any index created without explicitly specifying the number_of_shards will have 5 shards and the default number_of_replicas is 1.

For your concrete question :

PUT index1
{
    "settings" : {
        "index" : {
            "number_of_shards" : 5
        }
    }
}

The above can be omitted as the default number_of_shards is 5.

PUT index2
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3
        }
    }
}

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