python - Is there a way to set TTL on a document within AWS Elasticsearch utilizing python library?
问题描述
I can't find anyway to setup TTL on a document within AWS Elasticsearch utilizing python elasticsearch library.
I looked at the code of the library itself, and there are no argument for it, and I yet to see any answers on google.
解决方案
没有,如果你愿意,你可以使用索引管理策略,它将在索引级别操作,而不是在文档级别。您有一点回旋余地,因为您可以创建一个模式data-*
并拥有多个索引,data-expiring-2020-...
, data-keep-me
.
您可以将模板应用于模式data-expiring-*
并设置转换以在 20 天后删除索引。如果您每天滚动到一个新索引,那么一旦超过 20 天,您将在一天结束时删除最早的一天。
这种方法更可取,因为如果您要删除可能会消耗大量集群容量的单个文档,而不是删除整个分片。其他 NoSQL 数据库(例如 DynamoDB)以类似的方式运行,通常您可以做的是向您的docs
例如添加另一个字段deletionDate
并将其添加到您的查询中以过滤掉标记为删除但在您的索引中仍然存在的文档作为删除作业尚未清理它们。这也是 DynamoDB 中 TTL 的行为方式,数据不会在 TTL 过期的那一刻被删除,而是分批删除以提高性能。
推荐阅读
- android - FireBase Firestore 按 ID 列表检索多个文档
- authentication - VS 2017 ASP.NET Core Web 应用程序和个人用户帐户有效,但页面不存在
- graph - 如何按特定顺序遍历有向无环图的所有节点?
- jmeter - Jmeter-如何一次从数组中传递固定数量的值,直到遍历所有值到http请求
- selenium - 如何单击引用不同元素的按钮?
- powershell - 计算对象的属性
- javascript - Javascript S3 GET桶(列表对象)格式化?
- spring - api响应中的值为空
- mysql - 错误代码:1064。无法将数据插入数据库
- python - 条件数据帧移位