如何定期删除弹性搜索索引? [英] How to delete elastic search indices periodically?

查看:131
本文介绍了如何定期删除弹性搜索索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每天都创建了索引来存储搜索历史记录,我正在使用这些索引来建立我的应用,这有助于我根据历史建议。


$ b $现在我必须保持最近10天的历史。弹性搜索中有哪些功能可以定期创建和删除索引?

解决方案

唯一可以想到的正在使用数据数学:
https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html



有意义你可以这样做:

  DELETE< logs- {now%2Fd-10d}> 

由于url编码,这不会很好地卷曲。您可以在卷曲中执行此操作:

  curl -XDELETE'localhost:9200 /< logs-%7Bnow%2Fd- 10d%7D>'

两个示例都删除了10天的索引。它不会帮助您删除超过10天的索引,不要以为这是可能的。而且他们是没有触发或弹性的东西。



所以我会坚持一个cron工作与策展人的结合,但你也有这样的选择。


I have created indices on daily basis to store the search history and i am using those indices for the suggestions in my applciation, which helps me to suggest based on history as well.

now i have to maintain only last 10 days of history. So is there any feature in Elastic search that allows me to create and delete indices periodically?

解决方案

The only thing I can think of is using data math: https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html

In sense you can do this:

DELETE <logs-{now%2Fd-10d}>

This does not work nice in curl though due to url encoding. You can do something like this in curl:

curl -XDELETE 'localhost:9200/<logs-%7Bnow%2Fd-10d%7D>'

Both examples remove the index that is 10 days old. It does not help you in deleting indices older than 10 days, don't think that is possible. And their is no trigger or something in elasticsearch.

So I would stick to a cron job in combination with curator, but you do have this option to go with as well.

这篇关于如何定期删除弹性搜索索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆