0
功能我想出來的日期範圍聚集elasticsearch 2.3。我想將它們彙總爲過去30天,過去7天和今天。因此,我聚合查詢的一部分,如下所示:問題與現在elasticsearch
"range": {
"ranges": [
{
"from": "now-30d/d",
"to": "now/d"
},
{
"from": "now-7d/d",
"to": "now/d"
},
{
"from": "now/d",
"to": "now+1d/d"
}
],
"format": "yyyy-MM-dd"
}
這是造成在下面的桶:
"buckets": [
{
"key": "2017-01-23-2017-02-22",
"from": 1485129600000,
"from_as_string": "2017-01-23",
"to": 1487721600000,
"to_as_string": "2017-02-22",
"doc_count": 6
},
{
"key": "2017-02-15-2017-02-22",
"from": 1487116800000,
"from_as_string": "2017-02-15",
"to": 1487721600000,
"to_as_string": "2017-02-22",
"doc_count": 6
},
{
"key": "2017-02-22-2017-02-23",
"from": 1487721600000,
"from_as_string": "2017-02-22",
"to": 1487808000000,
"to_as_string": "2017-02-23",
"doc_count": 0
}
]
date
命令的在安裝elasticsearch機器的輸出如下所示:
Tue Feb 21 23:01:59 PST 2017
由於從桶看出,elasticsearch功能now
評估爲2017-02-22
,但我希望它是2017-02-21
。我在這裏錯過了什麼?
在此先感謝。
現在不受time_zone參數的影響(日期必須存儲爲UTC)。試着改變你的時區爲UTC – user3775217
https://discuss.elastic.co/t/several-date-math-questions/27453/4 – user3775217