gpt4 book ai didi

php - 删除超过一小时的文档在Elasticsearch中不起作用

转载 作者:行者123 更新时间:2023-12-03 01:29:14 25 4
gpt4 key购买 nike

我是Elasticsearch的新手,我在Elasticsearch中有一个文档,并且该文档包含成千上万的用户 View ,现在我要删除那些早于3小时的 View ,为此我在Elasticsearch中编写以下查询

POST {INDEX}/_delete_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"type": "box_views"
}
},
{
"query": {
"range": {
"@created_at": {
"gte": "now-3h"
}
}
}
}
]
}
}
}

当我执行此查询时,出现以下错误

{ "error": { "root_cause": [ { "type": "parsing_exception", "reason": "no [query] registered for [query]", "line": 1, "col": 66 } ], "type": "parsing_exception", "reason": "no [query] registered for [query]", "line": 1, "col": 66 }, "status": 400 }

最佳答案

您的查询应如下所示:

POST {INDEX}/_delete_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"type": "box_views"
}
},
{
"range": {
"@created_at": {
"gte": "now-3h"
}
}
}
]
}
}
}

此外,如果您正在寻找较旧的文档,我认为您应该使用 lte而不是 gte

关于php - 删除超过一小时的文档在Elasticsearch中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56802169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com