I've started reindexing some of my data from one index to another using the Reindex API. The problem is that now I want to stop the reindexing process, even though it has not finished. I'm able to see the process running with this command:
GET _tasks?detailed=true&actions=*reindex
But, how can I stop it?
EDIT: Stopping the whole cluster is not a possibility because it is being used for other purposes at the same time.
Calling the _tasks/<id>/_cancel endpoint only signifies to ES that the task should be cancelled. ES will then cancel the task as soon as it possibly can.
Reindex is the concept of copying existing data from a source index to a destination index which can be inside the same or a different cluster. Elasticsearch has a dedicated endpoint _reindex for this purpose. A reindexing is mostly required for updating mapping or settings.
You can use the Cancel Task API if the Task is cancellable
Quoting from documentation
Any Reindex can be canceled using the Task Cancel API:
POST _tasks/node_id:task_id/_cancel
The task_id can be found using the Tasks API.
Cancelation should happen quickly but might take a few seconds. The Tasks API will continue to list the task until it wakes to cancel itself.
Using the command below, get the task ID and follow
GET _tasks?detailed=true&actions=*reindex
Use the id
given out from the command and cancel using the Task API
"tasks" : {
"r1A2WoRbTwKZ516z6NEs5A:36619" : {
"node" : "r1A2WoRbTwKZ516z6NEs5A",
"id" : 36619,
"type" : "transport",
"action" : "indices:data/write/reindex",
.....
}
This is the one that worked for me.
POST _tasks/_cancel?nodes=node_id&actions=*reindex
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With