How can I find out the number of routing shards an index was created with? I tried using the Get Index Settings API, but it doesn't show up there:
# Create the Index
PUT twitter
{
"settings": {
"index": {
"number_of_shards": 5,
"number_of_routing_shards": 20
}
}
}
# Get the settings
GET twitter/_settings
which doesn't tell me the number of routing shards. I even tried querying the setting directly, but GET twitter/_settings/index.number_of_routing_shards just returns { }
Hm, indeed. This always seems to be "1", which is a fallback, but it should actually work with a multipler of the number of shards. Let me check that tomorrow and come back to you.
Looks like a possible workaround mentioned in that issue is to call the _split API with an invalid number of target shards, and the error response will include the number of routing shards.
So in this example you could try
POST twitter/_split/target-index
{
"settings": {
"index.number_of_shards": 15
}
}
{
"error": {
"root_cause": [
{
"type": "illegal_state_exception",
"reason": "the number of routing shards [20] must be a multiple of the target shards [15]"
}
],
"type": "illegal_state_exception",
"reason": "the number of routing shards [20] must be a multiple of the target shards [15]"
},
"status": 500
}
The problem is you could potentially pick a valid number and split the index. To be safer, you could try setting index.number_of_shards to a very high number, making it unlikely that the number of routing shards is a multiple. Probably a better solution is to just use templates and trust the setting in the template is correct.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.