Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop reindexing in Elasticsearch?

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.

like image 695
Drubio Avatar asked Sep 19 '18 16:09

Drubio


People also ask

How do I stop a task in Elasticsearch?

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.

What is Reindexing in elastic search?

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.


2 Answers

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",
      .....
}
like image 89
Polynomial Proton Avatar answered Oct 26 '22 07:10

Polynomial Proton


This is the one that worked for me.

POST _tasks/_cancel?nodes=node_id&actions=*reindex

like image 20
CedricYao Avatar answered Oct 26 '22 06:10

CedricYao