我想在弹性搜索中删除_type = varnish-request的所有文档。 我安装了delete by query插件(https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html)
我做了DELETE http://localhost:9200/logstash * / _ query
{
"query": {
"bool": {
"must": [
{ "match": {"_type":"varnish-request"}},
{ "match": {"_index":"logstash-2016.02.05"}}
]
}
}
}
没关系
{"took":2265842,"timed_out":false,"_indices":{"_all":{"found":3062614,"deleted":3062614,"missing":0,"failed":0},"logstash-2016.02.05":
{"found":3062614,"deleted":3062614,"missing":0,"failed":0}},"failures":[]}
curl http://localhost:9200/_cat/indices |分类 在干净之前
干净后
重点是“轻松”。我的ES服务器删除无用的数据。但在这里我看到索引大小仍然相同。
我已经检查Delete documents of type in Elasticsearch但没有运气
我尝试使用elasticsearch: how to free store size after deleting documents
POST http://localhost:9200/logstash-2016.02.05/_forcemerge
{"_shards":{"total":10,"successful":5,"failed":0}}
但仍然
答案 0 :(得分:2)
第一步是正确的。现在,您只需启用only_expunge_deletes
即可致电_optimize
(或_forcemerge
,如果您使用的是ES 2.1+)。这将删除包含已删除文档的段并释放一些空间。
curl -XPOST 'http://localhost:9200/_optimize?only_expunge_deletes=true'
或
curl -XPOST 'http://localhost:9200/_forcemerge?only_expunge_deletes=true'