英文:
Run ISM Policy Opensearch with query
问题
我想创建一个策略,根据索引中的"expired_time"字段来删除日志。
示例:
索引:my-log
数据:
{
"logText": "消息文本",
"expired_time": "2024-02-01T14:33:33.290+00:00"
}
根据我的研究,只能通过模式索引来删除它。所以有什么方法可以处理它吗?
使用:opensearch 1.0.1
英文:
i want to create policy to delete logs base on "expired_time" field in index.
Example:
index: my-log
data:
{
"logText":"message text",
"expired_time": "2024-02-01T14:33:33.290+00:00"
}
As i research, it can only be deleted by pattern index. So anyway i can process it?
Using: opensearch 1.0.1
答案1
得分: 1
There was a _ttl field to delete documents after the retention period. But the feature is removed.
> The _ttl mappings have been removed. As a replacement for _ttl
> mappings, we recommend using ILM (ISM in Opensearch) to create time-based indices.
What you can do?
You can use _delete_by_query API to remove documents older than X
times. It can make sense to trigger this query per hour.
An example:
POST index_name/_delete_by_query?conflicts=proceed
{
"query": {
"range": {
"expired_time": {
"lt": "now"
}
}
}
}
英文:
There was a _ttl field to delete documents after the retention period. But the feature is removed.
> The _ttl mappings have been removed. As a replacement for _ttl
> mappings, we recommend using ILM (ISM in Opensearch) to create time-based indices.
What you can do?
You can use _delete_by_query API to remove documents older than X
times. It can make sense to trigger this query per hour.
An example:
POST index_name/_delete_by_query?conflicts=proceed
{
"query": {
"range": {
"expired_time": {
"lt": "now"
}
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论