我想从ElasticSearch中删除数据。我已经删除了索引。然而,这似乎并没有真正删除数据本身。我看到的其他东西指向通过查询删除功能。然而,我甚至不知道该问什么。我知道指数。本质上,我想知道如何做a

DELETE FROM [Index]

从邮递员在Chrome。然而,我没有任何运气。似乎无论我做什么,数据都不会消失。到目前为止,我已经成功地删除索引使用DELETE HTTP动词在邮差和使用一个url:

   http://localhost:9200/[indexName]

然而,这似乎并没有真正删除数据(又名文档)本身。


当前回答

假设我需要删除索引filebeat-7.6.2-2020.04.30-000001,我使用curl delete选项执行它(curl -X delete "localhost:9200/filebeat-7.6.2-2020.04.30-000001?pretty"),并导致如下所示的身份验证问题;

{
  "error" : {
    "type" : "security_exception",
    "reason" : "missing authentication credentials for REST request [/filebeat-7.6.2-2020.04.30-000001?pretty]"
  },
  "status" : 401
}

在这里,您应该使用为Elasticsearch提供的用户名和密码对curl请求进行身份验证。然后试着

curl -X DELETE -u myelasticuser:myelasticpassword "localhost:9200/filebeat-7.6.2-2020.04.30-000001?漂亮”

将导致{ “acknowledge”:正确 }。

其他回答

在python中可以这样删除索引

from elasticsearch import Elasticsearch

es = Elasticsearch([{'host':'localhost', 'port':'9200'}])

es.index(index='grades',doc_type='ist_samester',id=1,body={
    "Name":"Programming Fundamentals",
    "Grade":"A"
})

es.indices.delete(index='grades')

我想删除logstash索引,并搜索了很多关于不同的工具,如curl。但最后找到了解决方案。 登录到Kibana。进入开发工具选项卡,在查询字段中输入DELETE /logstash-*,然后点击绿色箭头按钮。如果你得到“acknowledge”:true作为响应,这意味着数据已经被清除。

您可以删除整个索引,文档类型或一个特定的id数据。 这是三种方法:

curl -XDELETE localhost:9200/index_name curl -XDELETE localhost:9200/index_name/doc-type curl -XDELETE localhost:9200/index_name/doc-type/ documententid

如果你想删除所有索引,那么使用通配符。

1. 删除火

从指定索引中移除文档。

DELETE /<index>/_doc/<_id>

例子:

DELETE http://localhost:9200/my-index-000001/_doc/1

参考:ES指南>>删除API

2. 通过查询API删除

删除与指定查询匹配的文档。

例子:

POST http://localhost:9200/my-index-000001/_delete_by_query
{
  "query": {
      "match": {
           "user.id": "elkbee"
      }
   }
}

参考:ES指南>>根据查询API删除

你也可以使用chrome扩展elasticsearch-head删除索引