如何在 ElasticSearch 中为索引设置 TTL

How to set a TTL for an index in ElasticSearch

我想知道如何设置 TTL,以便 ES 集群自动删除超过 30 天的每个文档。

我知道以前的版本使用 TTL 字段来管理它,但现在它似乎已被删除。

我正在使用 NEST.NET 6.4.0

5.0 中删除了 TTL

您可以使用 curator ,将其安排为 cronjob 或 jenkins 作业,并一起删除旧索引。

curator_cli --host  localhost --port 9200 --http_auth "$USER":"$PASS" \
delete_indices --ignore_empty_list --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":30}, \
{"filtertype":"pattern","kind":"prefix","value":"livelogs"}]'

另请参阅: