Files
honeymoose f321dfedf5 同步完成!
**同步结果摘要**:

| 目录 | 同步前 | 同步后 | 官方 |
|------|--------|--------|------|
| aggregations | 40 | 65 | 64 |
| analyzers | 8 | 141 | 140 |
| api-reference | 97 | 186 | 174 |
| benchmark | 34 | 67 | 53 |
| clients | 17 | 18 | 18 |
| dashboards | 38 | 149 | 131 |
| data-prepper | 77 | 134 | 123 |
| im-plugin | 22 | 37 | 37 |
| ingest-pipelines | 27 | 52 | 51 |
| install-and-configure | 37 | 57 | 53 |
| ml-commons-plugin | 81 | 157 | 155 |
| observing-your-data | 39 | 73 | 66 |
| query-dsl | 40 | 77 | 75 |
| search-plugins | 80 | 139 | 95 |
| security-analytics | 22 | 47 | 46 |

**说明**:
- 本地文件数 > 官方:本地有一些官方已删除或重命名的文件
- 新增了约 **740 个英文文档文件**
- 已有文件保持不变(未覆盖)
2026-11-30 10:48:30 -05:00

98 lines
2.9 KiB
Markdown

---
layout: default
title: Delete task
parent: Tasks APIs
nav_order: 30
---
# Delete Task API
**Introduced 3.9**
{: .label .label-purple }
Use the Delete Task API to delete the stored result of a completed task. For example, when you run a supported operation and set `wait_for_completion=false`, OpenSearch stores the task result so that you can retrieve it later by using the [Get Task API]({{site.url}}{{site.baseurl}}/api-reference/tasks/get-tasks/). When you no longer need the result, delete it to free the associated storage.
The Delete Task API does not cancel or delete a running task. To stop a running task, use the [Cancel Tasks API]({{site.url}}{{site.baseurl}}/api-reference/tasks/cancel-tasks/).
{: .important }
<!-- spec_insert_start
api: tasks.delete
component: endpoints
-->
## Endpoints
```json
DELETE /_tasks/{task_id}
```
<!-- spec_insert_end -->
<!-- spec_insert_start
api: tasks.delete
component: path_parameters
-->
## Path parameters
The following table lists the available path parameters.
| Parameter | Required | Data type | Description |
| :--- | :--- | :--- | :--- |
| `task_id` | **Required** | String | The ID of the stored completed task result to delete (`node_id:task_number`). |
<!-- spec_insert_end -->
## Example request
The following request deletes the stored result for task `JzrCxdtFTCO_RaINw8ckNA:54321`:
<!-- spec_insert_start
component: example_code
rest: DELETE /_tasks/JzrCxdtFTCO_RaINw8ckNA:54321
-->
{% capture step1_rest %}
DELETE /_tasks/JzrCxdtFTCO_RaINw8ckNA:54321
{% endcapture %}
{% capture step1_python %}
response = client.tasks.delete(
task_id = "JzrCxdtFTCO_RaINw8ckNA:54321"
)
{% endcapture %}
{% include code-block.html
rest=step1_rest
python=step1_python %}
<!-- spec_insert_end -->
## Example response
OpenSearch responds with an acknowledgment after deleting the stored result:
```json
{
"acknowledged": true
}
```
After a successful deletion, the Get Task API returns a `404 Not Found` response for the task.
## Parent and child tasks
You cannot delete a stored task result while it has running child tasks or stored child task results. In a hierarchy of stored task results, delete the results from the leaves toward the root. For example, delete a grandchild result before its parent result, and then delete the root result.
OpenSearch returns a `409 Conflict` response if the task has running child tasks or stored child task results.
## Response codes
The following table lists common response codes.
| HTTP status code | Description |
| :--- | :--- |
| `200 OK` | The stored completed task result was deleted. |
| `404 Not Found` | The task is not running and has no stored result. |
| `409 Conflict` | The task is still running, is not marked as completed, has running child tasks, or has stored child task results. |
## Required permissions
If you use the Security plugin, make sure you have the appropriate permissions: `cluster:admin/tasks/delete`.