本文翻译自:Removing Data From ElasticSearch
I'm new to ElasticSearch . 我是ElasticSearch的新手 。 I'm trying to figure out how to remove data from ElasticSearch. 我试图弄清楚如何从ElasticSearch中删除数据。 I have deleted my indexes. 我已删除索引。 However, that doesn't seem to actually remove the data itself. 但是,这似乎并没有真正删除数据本身。 The other stuff I've seen points to the Delete by Query feature. 我看到的其他内容指向“ 按查询删除”功能。 However, I'm not even sure what to query on. 但是,我什至不知道要查询什么。 I know my indexes. 我知道我的索引。 Essentially, I'd like to figure out how to do a 本质上,我想弄清楚如何做
DELETE FROM [Index]
From PostMan in Chrome. 来自Chrome中的PostMan。 However, I'm not having any luck. 但是,我没有任何运气。 It seems like no matter what I do, the data hangs around. 看来,无论我做什么,数据都会徘徊。 Thus far, I've successfully deleted the indexes by using the DELETE HTTP Verb in PostMan and using a url like: 到目前为止,我已经通过在PostMan中使用DELETE HTTP Verb并使用如下网址来成功删除了索引:
http://localhost:9200/[indexName]
However, that doesn't seem to actually remove the data (aka docs) themselves. 但是,这似乎并没有实际删除数据(aka文档)本身。
#1楼
参考:https://stackoom.com/question/1YBem/从ElasticSearch删除数据
#2楼
You have to send a DELETE
request to 您必须将DELETE
请求发送给
http://[your_host]:9200/[your_index_name_here]
You can also delete a single document: 您还可以删除单个文档:
http://[your_host]:9200/[your_index_name_here]/[your_type_here]/[your_doc_id]
I suggest you to use elastichammer . 我建议您使用弹性锤 。
After deleting you can look up if the index still exists with the following URL: http://[your_host]:9200/_stats/
删除后,您可以使用以下URL查找索引是否仍然存在: http://[your_host]:9200/_stats/
Good luck! 祝好运!
#3楼
You can delete using cURL
or visually using one of the many tools that open source enthusiasts have created for Elasticsearch. 您可以使用cURL
删除,也可以使用开源爱好者为Elasticsearch创建的众多工具之一直观地删除。
Using cURL 使用cURL
curl -XDELETE localhost:9200/index/type/documentID
eg 例如
curl -XDELETE localhost:9200/shop/product/1
You will then receive a reply as to whether this was successful or not. 然后,您将收到有关此操作是否成功的答复。 You can delete an entire index or types with an index also, you can delete a type by leaving out the document ID like so - 您可以删除整个索引或带有索引的类型,也可以通过省略文档ID来删除类型,如下所示-
curl -XDELETE localhost:9200/shop/product
If you wish to delete an index - 如果您要删除索引-
curl -XDELETE localhost:9200/shop
If you wish to delete more than one index that follows a certain naming convention (note the *
, a wildcard), - 如果您希望删除多个遵循特定命名约定的索引(请注意*
,通配符),-
curl -XDELETE localhost:9200/.mar*
Visually 视觉上
There are various tools as mentioned above, I wont list them here but I will link you to one which enables you to get started straight away, located here . 有各种工具,如上面提到的,我不会一一列举,但我会联系你一个使您能够得到马上开始,位于这里 。 This tool is called KOPF, to connect to your host please click on the logo on top left hand corner and enter the URL of your cluster. 此工具称为KOPF,要连接到主机,请单击左上角的徽标,然后输入群集的URL。
Once connected you will be able to administer your entire cluster, delete, optimise and tune your cluster. 连接后,您将能够管理整个集群,删除,优化和调整集群。
#4楼
If you ever need to delete all the indexes, this may come in handy: 如果您需要删除所有索引,这可能会派上用场:
curl -X DELETE 'http://localhost:9200/_all'
Powershell: 电源外壳:
Invoke-WebRequest -method DELETE http://localhost:9200/_all
#5楼
For mass-delete by query you may use special delete by query API : 对于按查询批量删除,您可以使用特殊的按查询删除API :
$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{
"query" : {
"term" : { "user" : "kimchy" }
}
}
In history that API was deleted and then reintroduced again 历史上曾删除过API,然后又重新引入了
Who interesting it has long history. 谁很有趣,历史悠久。
- In first version of that answer I refer to documentation of elasticsearch version 1.6 . 在该答案的第一个版本中,我指的是Elasticsearch 1.6版的文档。 In it that functionality was marked as deprecated but works good. 在该功能中,该功能被标记为已弃用,但效果很好。
- In elasticsearch version 2.0 it was moved to separate plugin . 在Elasticsearch 2.0版中,它已移至单独的插件 。 And even reasons why it became plugin explained . 甚至解释了为什么它成为插件的原因。
- And it again appeared in core API in version 5.0 ! 它再次出现在5.0版的核心API中 !
#6楼
The documentation (or The Definitive Guide ) says, that you can also use the next query to delete all indices: 文档 (或《权威指南》 )说,您还可以使用下一个查询来删除所有索引:
curl -XDELETE 'http://localhost:9200/*'
And there's an important note: 还有一个重要的注意事项:
For some, the ability to delete all your data with a single command is a very scary prospect. 对于某些人来说,使用单个命令删除所有数据的能力是一个非常可怕的前景。 If you want to eliminate the possibility of an accidental mass-deletion, you can set the following to
true
in yourelasticsearch.yml
: 如果要消除意外的大量删除的可能性,可以在elasticsearch.yml
中将以下设置为true
:
action.destructive_requires_name: true