我制定了政策,并应用了指数政策。此策略允许我们为文档设置过期时间。一旦时间过去了,过期的文档就会被删除。
最新版本的Elasticsearch有可能吗?
发布于 2022-09-11 03:25:05
据我所知,ILM删除整个索引,标准是索引创建后的天数。如果您需要删除特定的文档,我认为您需要利用API来实现这一点。您可以设置一个cron作业,它使用下面的脚本来删除特定的文档。
curl -k -X POST "https://USERNAME:PASSWORD@localhost:9200/test/_delete_by_query?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"lt": "now-30d"
}
}
}
]
}
}
}参考资料:https://discuss.elastic.co/t/automatically-delete-older-documents/247078/9
https://stackoverflow.com/questions/73657492
复制相似问题