首页 > 解决方案 > elasticsearch / kibana错误的纪元日期索引

问题描述

elastichsearch 或 kibana 从纪元索引开始出现错误的日期。

the date value is: 1495956650 (human date: GMT: Sunday, May 28, 2017 7:30:50 AM)

但是......当将此记录索引到具有以下映射的elasticsearch时:

PUT test
{
    "mappings": {
    "doc": {
      "properties": {
        "date": {
                    "properties": {
                      "value": {
                        "type": "date"
                      }
                    }
                  }
          }
        }
      }
}

何时发布此数据:

POST test/doc
{"date": {
          "value": "1495956650"
        } 
}

我在索引模式之后在 kibana 中看到了这个日期,那是错误的!

date.value:January 18th 1970, 11:02:36.650

我的 elasticsearch 和 kibana 版本都是 6.2.3,我的系统时间是更新的。

标签: elasticsearchkibana

解决方案


看起来 elasticsearch 已经“猜测”epoch_millis而不是epoch_second.

您需要按如下方式调整映射:

PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "date": {
          "properties": {
            "value": {
              "type": "date",
              "format": "epoch_second"
            }
          }
        }
      }
    }
  }
}

有关此处提供的弹性搜索日期格式的更多信息


推荐阅读