私は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
}
]
次のようにelasticsearchがインストールされているマシンでdate
コマンドの出力である:
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