All methods and paths for this operation:
Split an index into a new index with more primary shards.
Before you can split an index:
The index must be read-only.
The cluster health status must be green.
You can do make an index read-only with the following request using the add index block API:
PUT /my_source_index/_block/write
The current write index on a data stream cannot be split. In order to split the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be split.
The number of times the index can be split (and the number of shards that each original shard can be split into) is determined by the index.number_of_routing_shards setting.
The number of routing shards specifies the hashing space that is used internally to distribute documents across shards with consistent hashing.
For instance, a 5 shard index with number_of_routing_shards set to 30 (5 x 2 x 3) could be split by a factor of 2 or 3.
A split operation:
IMPORTANT: Indices can only be split if they satisfy the following requirements:
managePeriod to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
The number of shard copies that must be active before proceeding with the operation.
Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1).
Values are all or index-setting.
POST /my-index-000001/_split/split-my-index-000001
{
"settings": {
"index.number_of_shards": 2
}
}
resp = client.indices.split(
index="my-index-000001",
target="split-my-index-000001",
settings={
"index.number_of_shards": 2
},
)
const response = await client.indices.split({
index: "my-index-000001",
target: "split-my-index-000001",
settings: {
"index.number_of_shards": 2,
},
});
response = client.indices.split(
index: "my-index-000001",
target: "split-my-index-000001",
body: {
"settings": {
"index.number_of_shards": 2
}
}
)
$resp = $client->indices()->split([
"index" => "my-index-000001",
"target" => "split-my-index-000001",
"body" => [
"settings" => [
"index.number_of_shards" => 2,
],
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"settings":{"index.number_of_shards":2}}' "$ELASTICSEARCH_URL/my-index-000001/_split/split-my-index-000001"
{
"settings": {
"index.number_of_shards": 2
}
}