前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Elasticsearch Delete By Query Plugin4

Elasticsearch Delete By Query Plugin4

作者头像
franket
发布2022-01-20 11:56:52
2990
发布2022-01-20 11:56:52
举报
文章被收录于专栏:技术杂记

也可以使用如下DSL

代码语言:javascript
复制
[root@esdbqp bin]# curl -XDELETE "http://localhost:9200/filebeat-2016.01.28/log/_query?pretty=true" -d '
{
 "query": {
   "term": {
      "tags": "multiline"
    }
  }
}'
{
  "took" : 0,
  "timed_out" : false,
  "_indices" : {
    "_all" : {
      "found" : 0,
      "deleted" : 0,
      "missing" : 0,
      "failed" : 0
    }
  },
  "failures" : [ ]
}
[root@esdbqp bin]#

我觉得CLI下面这种方法比较麻烦

Tip:

  • 不加 pretty=true 输出仍然为jason,但因为没有换行,显示会很凌乱
  • 事实上这个插件也还是使用的 scrollbulk 的方式在内部进行实现的

Internally, the query is used to execute an initial scroll request. As hits are pulled from the scroll API, they are passed to the Bulk API for deletion.

执行结果显示正常删除了110条记录

进行查看,剩下4104条,而原来总共4214条,确实是删掉了这么多

代码语言:javascript
复制
[root@esdbqp bin]# curl "http://localhost:9200/filebeat-*/log/_search?pretty=true&q=tags:multiline" | head -n 20 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12576  100 1  0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
{
  "took" : 120,
  "timed_out" : false,
  "_shards" : {
    "total" : 165,
    "successful" : 165,
    "failed" : 0
  },
  "hits" : {
    "total" : 4104,
    "max_score" : 9.852164,
    "hits" : [ {
      "_index" : "filebeat-2016.01.29",
      "_type" : "log",
      "_id" : "AVKLW366FoV7cO-daoBe",
      "_score" : 9.852164,
      ...
      ...
      ...

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档