datetime - Elasticsearch聚合不同时区
问题描述
我正在尝试查看直方图除以一天中的小时数。
问题是时区:如果我在美国早上 8 点和欧洲早上 8 点放一个文件,我有不同的时区,但在图表中我想在同一时间汇总它们。
所以我的结果应该是上午 8 点的2 个文档计数
我的实际数据:
[
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"my_time" : "2021-09-17T08:00:00.000-04:00",
"value" : 1
}
},
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"my_time" : "2021-09-17T08:00:00.000+02:00",
"value" : 2
}
},
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"my_time" : "2021-09-17T03:00:00.000-04:00",
"value" : 3
}
},
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "4",
"_score" : 1.0,
"_source" : {
"my_time" : "2021-09-17T04:00:00.000-08:00",
"value" : 4
}
},
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "5",
"_score" : 1.0,
"_source" : {
"my_time" : "2021-09-17T23:00:00.000+04:00",
"value" : 5
}
}
]
在映射中
"my_time": {
"type": "date"
}
我的查询:
POST /test_index/_search?size=0
{
"aggs": {
"my_results": {
"date_histogram": {
"field": "my_time",
"calendar_interval": "1h"
}
}
}
}
但结果很糟糕!例如:
"buckets" : [
{
"key_as_string" : "2021-09-17T06:00:00.000Z",
"key" : 1631858400000,
"doc_count" : 1
},
{
"key_as_string" : "2021-09-17T07:00:00.000Z",
"key" : 1631862000000,
"doc_count" : 1
},
......
]
我该如何解决?
解决方案
推荐阅读
- html - 如何将视频导入我的 HTML 文件?我只知道怎么加GIF和IMG
- python - 如何在实时视频中将 python 代码从 2.5 加速到 30 FPS 或更高?
- javascript - 将 JS 回调函数合并到 RShiny DT::renderdatatable 选项中
- python-3.x - 将 Python 连接到 SharePoint 列表
- r - 平面 GLS 的曲面逼近
- bash - 避免删除 shell 文件夹内的多个子文件夹
- javascript - 通过 JSON 递归以将子键附加到父级
- python-3.x - 如何重新排列第一个元素包含多个值的列表列表,并在重复第一个元素的同时创建一个新的列表列表?
- python-3.x - 如何使用python解析数据框列中的数据
- python - 尝试使用以下代码运行烧瓶