Company
Date Published
Author
Christian Strzadala
Word count
1057
Language
-
Hacker News points
None

Summary

Elasticsearch's _ttl (Time to Live) mapping allows for setting expiration times on documents, leading to their automatic deletion after the specified period. However, the _ttl feature is deprecated, and its use is discouraged due to the inefficiency of the deletion process, where expired documents are marked for deletion but remain in the index until segment merges occur, causing performance issues. Instead, time-based indices are recommended, which involve using expiration fields for filtering and index aliases to improve query performance and reduce overhead. These indices allow for more efficient management by creating new indices based on time intervals and deleting entire indices when they are no longer needed, rather than handling numerous document deletions. However, certain data models, such as those requiring parent/child relationships, may not be suitable for time-based indices, and in such cases, alternative solutions or application-level TTL management should be considered. Additionally, the presence of Elasticsearch's Shield can create challenges in deleting documents with _ttl due to permission issues, though this does not affect time-based indices.