简体   繁体   English

弹性搜索可以删除索引中的所有数据吗

[英]elastic search can I delete all the data in an index

First of all, I have already checked this question Removing Data From ElasticSearch 首先,我已经检查了这个问题, 从ElasticSearch中删除数据

It's not good for me because the answers there are talking about how to delete the whole index., which is different from my question. 这对我不好,因为那里的答案是关于如何删除整个索引的,这与我的问题不同。

my question is that i want to delete the whole document inside one index, but without deleting the index. 我的问题是我想删除一个索引内的整个文档,但不删除索引。

i tried to do the flush command, but it doesn't delete anything. 我试图执行flush命令,但它不会删除任何内容。

thanks in advance 提前致谢

If you just need to delete the documents but keep your index, then you may use the delete by query plugin (if you are using ES 2.x) otherwise you may just use the delete by query API (if you're using ES 1.7.x or earlier). 如果您只需要删除文档但保留索引,则可以使用按查询删除插件(如果使用的是ES 2.x),否则可以只按查询查询API使用删除的 (如果您使用的是ES 1.7) .x或更早版本)。

So if you're using ES 2.x, first install the plugin with the command below and restart ES 因此,如果您使用的是ES 2.x,请首先使用以下命令安装插件,然后重新启动ES

bin/plugin install delete-by-query

Then you can delete all your documents with the following curl 然后,您可以使用以下curl删除所有文档

curl -XDELETE http://localhost:9200/index/_query?q=*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM