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

推荐订阅源

量子位
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
V
Visual Studio Blog
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Jina AI
Jina AI
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
The Cloudflare Blog
小众软件
小众软件
雷峰网
雷峰网
V
V2EX
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow 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#