首页/数据/NoSQL 速查/_tasks 查看与取消长任务
Elasticsearch89 条

_tasks 查看与取消长任务

任务接口列出正在执行的集群任务(搜索、reindex、force merge 等)及耗时;需要中断时用任务 ID 取消,是排查长任务与资源占用的关键入口。

NoSQL 速查数据更新于 2026-10-12
接口GET /_tasks?detailed=true&actions=*_search 或 GET /_tasks/<task_id>
取消POST /_tasks/<task_id>/_cancel
常用过滤actions=*reindex、nodes=<node_id>、group_by=parents

示例

示例
GET /_tasks?detailed=true&actions=*reindex
GET /_tasks?group_by=parents&human=true
POST /_tasks/oTUltX4IQMOUUVeiohTt74:42/_cancel
取消是协作式的:任务在检查点响应取消请求,搜索类任务通常能较快停止。

易错点

  • 任务 ID 是 nodeId:taskId 组合,跨请求复用前先确认任务仍在该节点上
  • 取消后资源不是立刻释放,仍可能在返回途中占用线程

数据来源与参考

  • Elasticsearch Guide: Task management API
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌