我正在使用Spark将日志写到elasticsearch.Logs是具有时间戳字段的JSON格式。

示例{ "timestamp": "2016-11-02 21:16:06.116" }
当我将Json日志写入Elastic index时,时间戳分析为String而不是日期。我尝试使用sparkConf.set("es.mapping.timestamp", "timestamp")在sparkconf中设置属性,但在运行时抛出以下错误:org.apache.spark.util.TaskCompletionListenerException:无法解析时间戳[2016-11-03 15:46:55.1155]

最佳答案

您可以更改时间戳记数据格式

2016-11-02 21:16:06.116-> 2016-11-02T21:16:06.116

我使用2016-11-02T21:16:06.116插入Elastic工作

类型属性

  "create_time": {
  "format": "strict_date_optional_time||epoch_millis",
  "type": "date"

关于elasticsearch - Spark中的时间戳映射到Elasticsearch,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40396575/

10-17 03:14