




















In Elasticsearch (ES), you can run a task and check its status with the task API.
For example, if you use the reindex API in ES with parameter with_for_completion=False,
ES will not wait for the process to finish and will return a task instead.
To check the running tasks, we can use:
This will return a list of running tasks.
You can also specify the query parameters, for example, to filter based on reindex action, you can use:
GET _tasks?action=*reindex*The above API will return response in JSON format. If you do not want to parse the result and just want to get human readable output, you can use cat task API:
GET _cat/tasks?action=*cluster*If you know the task id of a task, you can check its detailed status using the get task API:
GET _tasks/<your-task-id>It will show you if the task is completed, how long does it takes, and how many documents are processed etc.
To cancel a task, we can use the following API:
POST _tasks/<task-id>/_cancelNote this is a POST request instead of GET.
ref:
Currently there is no API to check finished tasks, unless you know the task id (use the get task API above to check task details).
However, all task information is stored in a special index .tasks.
We can query this index just like a normal index1. For example, you can do this:
GET .tasks/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"completed": true
}
},
{
"term": {
"task.action": "indices:data/write/reindex"
}
}
]
}
}
}The above query will filter tasks based on completion status and action type.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。