gpt4 book ai didi

date - 历史上的今天Elasticsearch

转载 作者:行者123 更新时间:2023-12-02 23:47:16 27 4
gpt4 key购买 nike

我想捕获今天的历史数据。
该查询返回空。我想忽略岁月。

"query": {
"bool": {
"filter": [
{
"range": {
"created_at": {
"gte": "02-15",
"lte": "02-15",
"format": "MM-dd"
}
}
}
]
}
}

最佳答案

https://www.elastic.co/blog/an-introduction-to-elasticsearch-sql-with-practical-examples-part-1我从文章中得到了帮助。

适应了我自己here

{
"query" : {
"bool" : {
"must" : [
{
"script" : {
"script" : {
"source" : "InternalSqlScriptUtils.nullSafeFilter(InternalSqlScriptUtils.eq(InternalSqlScriptUtils.dateTimeChrono(InternalSqlScriptUtils.docValue(doc,params.v0), params.v1, params.v2),params.v3))",
"lang" : "painless",
"params" : {
"v0" : "created_at",
"v1" : "Z",
"v2" : "DAY_OF_MONTH",
"v3" : 15
}
}
}
},
{
"script" : {
"script" : {
"source" : "InternalSqlScriptUtils.nullSafeFilter(InternalSqlScriptUtils.eq(InternalSqlScriptUtils.dateTimeChrono(InternalSqlScriptUtils.docValue(doc,params.v0), params.v1, params.v2),params.v3))",
"lang" : "painless",
"params" : {
"v0" : "created_at",
"v1" : "Z",
"v2" : "MONTH_OF_YEAR",
"v3" : 2
}
}
}
}
]
}
}
}

这就是我解决问题的方式。也许它将对其他人有用。

关于date - 历史上的今天Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60301001/

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