Elasticsearch version :
6.1.4 / 6.2.3
Plugins installed:
XPack
JVM version :
1.8.0_151
OS version :
Ubuntu 16.04 / CentOS 7.4
Description of the problem including expected versus actual behaviour:
The split index API requires that an index to be created with the setting number_of_routing_shards.
This means that this API cannot be used against existent indices that does not have the setting.
However, if you close the existent index, you are able to add the mentioned setting.
This operation should be blocked and an error message should also appear
Steps to reproduce:
1# POST my_source_index/_close
2# PUT my_source_index/_settings
{
"settings": {
"index.number_of_routing_shards": 15
}
}
3# POST my_source_index/_open
4# PUT my_source_index/_settings
{
"settings": {
"index.blocks.write": true
}
}
5# POST my_source_index/_split/my_target_index
{
"settings": {
"index.number_of_shards": 15
}
}
The error message that appears when trying to use the split index API is:
{
"error": {
"root_cause": [
{
"type": "illegal_state_exception",
"reason": "the number of routing shards [5] must be a multiple of the target shards [15]"
}
],
"type": "illegal_state_exception",
"reason": "the number of routing shards [5] must be a multiple of the target shards [15]"
},
"status": 500
Provide logs (if relevant):
N/A
Pinging @elastic/es-core-infra
It would be great if this could be fixed in a way that enables clients with older indices to update those indices (closed or open) to add/update this setting. In order to used the _split feature, the client would already need to know upon index creation that s/he will need to split the index and by what factor. That's a lot of foresight that is unlikely to be readily available in most cases. For this feature to be useful, we need to be able to update the parameter as needed.
+1
+1
+1
+1
+1
The docs are confusing, and maybe I'm misunderstanding @bosinm 's point but fwiw I did _not_ have to set index.number_of_routing_shards in order to use the _split api.
I'm using Elasticsearch 7.5.2. I was able to split an index created with 5 shards to 20.
# Split the index, e.g. from default 5 shards to 20. This will return
# an error if it's not a multiple of the current number of shards.
curl -XPUT -H 'Content-type: application/json' "http://elasticsearch:9200/${OLD_INDEX}/_split/${OLD_INDEX}_split20?pretty" --data-binary '
{
"settings": {
"index.number_of_shards": 20
}
}
'
UPDATE: doh sorry I just noticed this comment that the number_of_routing_shards requirement was removed in Elasticsearch 7.0, that's why I didn't need to set it.
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-split-index.html
The _split API requires the source index to be created with a specific number_of_routing_shards in order to be split in the future. This requirement has been removed in Elasticsearch 7.0.
Most helpful comment
It would be great if this could be fixed in a way that enables clients with older indices to update those indices (closed or open) to add/update this setting. In order to used the _split feature, the client would already need to know upon index creation that s/he will need to split the index and by what factor. That's a lot of foresight that is unlikely to be readily available in most cases. For this feature to be useful, we need to be able to update the parameter as needed.