gpt4 book ai didi

elasticsearch - 日期范围查询中的 Elasticsearch 间隔

转载 作者:行者123 更新时间:2023-12-03 00:50:20 28 4
gpt4 key购买 nike

我有一个查询应该是这样的要求:

{
"size": 0,
"_source": [
"dateCreated"
],
"query": {
"bool": {
"must": {
"range": {
"date_published": {
"from": "2019-01-01", //Fixed date
"to": "--15 days from given 'from' date--" //Cannot find solution for this
}
}
}
}
}
}

我找不到像这样的简单要求的文档。

最佳答案

使用date math可以实现您的期望

{
"size": 0,
"_source": [
"dateCreated"
],
"query": {
"bool": {
"must": {
"range": {
"date_published": {
"from": "2019-01-01",
"to": "2019-01-01||+15d"
}
}
}
}
}
}

关于elasticsearch - 日期范围查询中的 Elasticsearch 间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54767945/

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