Elasticsearch Delete By Query Plugin1

2022-01-20 11:35:50 浏览数 (1)

ES中有一些被标记为 multiline 的记录,我想删掉它们

代码语言:javascript复制
[root@esdbqp bin]# curl "http://localhost:9200/filebeat-*/_search?pretty=true&q=tags:multiline"
{
  "took" : 44,
  "timed_out" : false,
  "_shards" : {
    "total" : 165,
    "successful" : 165,
    "failed" : 0
  },
  "hits" : {
    "total" : 4214,
    "max_score" : 9.93189,
    "hits" : [ {
      "_index" : "filebeat-2016.01.28",
      "_type" : "log",
      "_id" : "AVKLW2hTFoV7cO-dan6I",
      "_score" : 9.93189,
      ...
      ...
      ...

当前的插件情况

代码语言:javascript复制
[root@esdbqp bin]# /usr/share/elasticsearch/bin/plugin list
Installed plugins in /usr/share/elasticsearch/plugins:
    - No plugin detected
[root@esdbqp bin]# 

报错1

当前尝试使用 Delete By Query API

代码语言:javascript复制
[root@esdbqp bin]# curl -XDELETE "http://localhost:9200/filebeat-*/log/_query?pretty=true&q=tags:multiline"
{
  "error" : {
    "root_cause" : [ {
      "type" : "invalid_index_name_exception",
      "reason" : "Invalid index name [filebeat-*], must not contain the following characters [\, /, *, ?, ", <, >, |,  , ,]",
      "index" : "filebeat-*"
    } ],
    "type" : "invalid_index_name_exception",
    "reason" : "Invalid index name [filebeat-*], must not contain the following characters [\, /, *, ?, ", <, >, |,  , ,]",
    "index" : "filebeat-*"
  },
  "status" : 400
}
[root@esdbqp bin]# curl -XDELETE "http://localhost:9200/filebeat-2016.01.02/log/_query?pretty=true&q=tags:multiline"
{
  "found" : false,
  "_index" : "filebeat-2016.01.02",
  "_type" : "log",
  "_id" : "_query",
  "_version" : 1,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  }
}
[root@esdbqp bin]#

说明在 ES2.1.1中的确已经删掉了这个API

Tip:在1.5.3的版本之前,上面的操作是直接可以成功的

0 人点赞