弹性搜索聚合中的动态时区偏移?

前端之家收集整理的这篇文章主要介绍了弹性搜索聚合中的动态时区偏移?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在汇总每个都有时间戳的文档.时间戳是UTC,但每个文档也有一个本地时区(“timezone”:“America / Los_Angeles”),它们可以在文档之间有所不同.

我正在尝试根据当地时间而不是UTC或固定时区进行date_histogram聚合(例如,使用选项“time_zone”:“America / Los_Angeles”).

如何在聚合之前将每个文档的时区转换为当地时间?

这是简单的聚合:

{
  "aggs": {
    "date": {
      "date_histogram": {
        "field": "created_timestamp","interval": "day"
      }
    }
  }
}

解决方法

我不确定我是否完全理解它,但似乎 time_zone property将是这样的:

The zone value accepts either a numeric value for the hours offset,for example: “time_zone” : -2. It also accepts a format of hours and minutes,like “time_zone” : “-02:30”. Another option is to provide a time zone accepted as one of the values listed here.

猜你在找的设计模式相关文章