Cancel a taskTechnical preview

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.

Query parameters

  • actionsstring | array[string]

    A comma-separated list or wildcard expression of actions that is used to limit the request.

  • nodesarray[string]

    A comma-separated list of node IDs or names that is used to limit the request.

  • A parent task ID that is used to limit the tasks.

  • If true, the request blocks until all found tasks are complete.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • node_failuresarray[object]
      Hide node_failures attributes Show node_failures attributes object
      • typestring Required

        The type of error

      • reasonstring

        A human-readable explanation of the error, in English.

      • The server stack trace. Present only if the error_trace=true parameter was sent with the request.

      • caused_byobject
      • root_causearray[object]
      • suppressedarray[object]
    • task_failuresarray[object]
      Hide task_failures attributes Show task_failures attributes object
      • task_idnumber Required
      • node_idstring Required
      • statusstring Required
      • reasonobject Required
        Hide reason attributes Show reason attributes object
        • typestring Required

          The type of error

        • reasonstring

          A human-readable explanation of the error, in English.

        • The server stack trace. Present only if the error_trace=true parameter was sent with the request.

        • caused_byobject
        • root_causearray[object]
        • suppressedarray[object]
    • nodesobject

      Task information grouped by node, if group_by was set to node (the default).

      Hide nodes attribute Show nodes attribute object
      • *object Additional properties
        Hide * attributes Show * attributes object
        • namestring
        • hoststring
        • ipstring
        • rolesarray[string]
        • Hide attributes attribute Show attributes attribute object
          • *string Additional properties
        • tasksobject Required
          Hide tasks attribute Show tasks attribute object
          • *object Additional properties
            Hide * attributes Show * attributes object
            • actionstring Required
            • cancelledboolean
            • cancellableboolean Required
            • 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 _reindex which has the source and the destination, or _bulk which 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.

            • headersobject Required
              Hide headers attribute Show headers attribute object
              • *string Additional properties
            • idnumber Required
            • nodestring Required
            • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

            • Time unit for nanoseconds

            • Time unit for milliseconds

            • 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.

            • typestring Required
    • tasksarray[object] | object

      One of:
      Hide attributes Show attributes object
      • actionstring Required
      • cancelledboolean
      • cancellableboolean Required
      • 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 _reindex which has the source and the destination, or _bulk which 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.

      • headersobject Required
        Hide headers attribute Show headers attribute object
        • *string Additional properties
      • idnumber Required
      • nodestring Required
      • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

      • Time unit for nanoseconds

      • Time unit for milliseconds

      • 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.

      • typestring Required
POST /_tasks/_cancel
curl \
 --request POST 'http://api.example.com/_tasks/_cancel' \
 --header "Authorization: $API_KEY"