Cancel a task
- POST /_tasks/{task_id}/_cancel
- POST /_tasks/_cancel
WARNING: The task management API is new and should still be considered a beta feature. The API may change in ways that are not backwards compatible.
A task may continue to run for some time after it has been cancelled because it may not be able to safely stop its current activity straight away. It is also possible that Elasticsearch must complete its work on other tasks before it can process the cancellation. The get task information API will continue to list these cancelled tasks until they complete. The cancelled flag in the response indicates that the cancellation command has been processed and the task will stop as soon as possible.
To troubleshoot why a cancelled task does not complete promptly, use the get task information API with the ?detailed parameter to identify the other tasks the system is running.
You can also use the node hot threads API to obtain detailed information about the work the system is doing instead of completing the cancelled task.
- Cluster privileges:
manage
Path Parameters
-
task_idnumber | string TaskIdoptional -
The task identifier.
Leave it out to use
/_tasks/_cancel.
Query Parameters
-
actionsstring | string A comma-separated list or wildcard expression of actions that is used to limit the request.
-
nodesstring A comma-separated list of node IDs or names that is used to limit the request.
-
parent_task_idstring A parent task ID that is used to limit the tasks.
-
wait_for_completionboolean · default: false If true, the request blocks until all found tasks are complete.
Response
-
node_failuresErrorCause -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
task_failuresTaskFailure -
task_idnumberrequired -
node_idstringrequired -
statusstringrequired -
reasonErrorCauserequired -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
nodesmap string to NodeTasks -
Task information grouped by node, if
group_bywas set tonode(the default). -
<string>NodeTasks -
namestring -
transport_addressstring -
hoststring -
ipstring -
rolesstring -
attributesmap string to string -
tasksmap string to TaskInforequired -
<string>TaskInfo -
actionstringrequired -
cancelledboolean -
cancellablebooleanrequired -
descriptionstring -
Human readable text that identifies the particular request that the task is performing. For example, it might identify the search request being performed by a search task. Other kinds of tasks have different descriptions, like
_reindexwhich has the source and the destination, or_bulkwhich just has the number of requests and the destination indices. Many requests will have only an empty description because more detailed information about the request is not easily available or particularly helpful in identifying the request. -
headersmap string to stringrequired -
idnumberrequired -
nodestringrequired -
running_timestring Duration -
running_time_in_nanosDurationValueUnitNanosrequired -
start_time_in_millisEpochTimeUnitMillisrequired -
statusobject -
The internal status of the task, which varies from task to task. The format also varies. While the goal is to keep the status for a particular task consistent from version to version, this is not always possible because sometimes the implementation changes. Fields might be removed from the status for a particular request so any parsing you do of the status might break in minor releases.
-
typestringrequired -
parent_task_idnumber | string TaskId -
tasksTaskInfos -
Either a flat list of tasks if
group_bywas set tonone, or grouped by parents ifgroup_bywas set toparents.