惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
罗磊的独立博客
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
V
V2EX
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
量子位
MyScale Blog
MyScale Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
B
Blog

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
How to Use the Elasticsearch task API
2024-08-16 · via jdhao's digital space

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.

Check running tasks#

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*

Get status of a task#

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.

Cancel a task#

To cancel a task, we can use the following API:

POST _tasks/<task-id>/_cancel

Note this is a POST request instead of GET.

ref:

Check info about finished tasks?#

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.

References#