有没有办法在弹性搜索索引中设置ttl [英] Is there a way to Set ttl in elastic search index
问题描述
我看到文档说我们可以在文档上设置 ttl
,但不能在索引/索引上设置。还想知道如果设置 ttl
是否会对性能产生影响。
_ttl
是已为每个索引启用,但有效期为每个文档。
如果您希望索引过期,请将其删除。
是的, _ttl
对性能有影响。
Elasticsearch处理过期数据的方式是创建基于时间的索引。意思是,您每天或每周都会创建一个索引。在该索引中索引属于该日/周的所有内容。您决定要保留多少天并坚持这个数字。
假设您要保留7天的数据。与往常一样,在第8天创建新索引,然后从前8天删除索引。您将一直拥有7个索引组。 ttl
机制检查每个 indices.ttl.interval
(默认为60秒)中是否有过期的文档,它会创建批量请求从中删除它们。
相反,删除索引非常简单快捷。
看看此以及如何轻松实现使用 Curator 管理基于时间的索引。。 p>
I can see that docs say that we can set ttl
on a document but not on index/indices. Also wanted to know if it has any performance impact if we set ttl
.
_ttl
is enabled per index, but the expiration works per document.
If you want your indices to "expire", delete them. Much more simple and performant.
And yes, _ttl
has a performance impact.
The Elasticsearch "way" of dealing with "expired" data is to create time-based indices. Meaning, for each day or each week you create an index. Index everything belonging to that day/week in that index. You decide how many days you want to keep around and stick to that number.
Let's say that you want to keep the data for 7 days. In the 8th day you create the new index, as usual, then you delete the index from 8 days before. All the time you'll have in your cluster 7 indices. The ttl
mechanism checks every indices.ttl.interval
(60 seconds by default) for expired documents, it creates bulk requests out of them and deletes them. This means unnecessary requests coming to the cluster.
Instead, deleting an index is very easy and quick.
Take a look at this and how to easily manage time based indices with Curator.
这篇关于有没有办法在弹性搜索索引中设置ttl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!