2 同时定义多种日期格式

在构建 mapping 的时候,可以通过用 || 分隔符,把多种日期格式写入,而在写入的时候,每种格式都会依次尝试转换,直到有匹配的为止。下面例子中可以,第一种格式就会尝试把毫秒值转换为 string

PUT my_index
{
  "mappings": {
    "_doc": {
      "properties": {
        "date": {
          "type":   "date",
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        }
      }
    }
  }
}

相关文章:

  • 2021-07-19
  • 2021-06-15
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2023-02-15
  • 2021-07-11
  • 2021-06-03
  • 2022-01-09
  • 2022-01-10
相关资源
相似解决方案