我有一个查询要求如下:
{
"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
}
}
}
}
}
}
我找不到像这样的简单要求的文档。
答案 0 :(得分:2)
使用date math,您可以实现期望的目标
{
"size": 0,
"_source": [
"dateCreated"
],
"query": {
"bool": {
"must": {
"range": {
"date_published": {
"from": "2019-01-01",
"to": "2019-01-01||+15d"
}
}
}
}
}
}