无法解析时间戳弹性搜索 [英] failed to parse timestamp elasticsearch

查看:78
本文介绍了无法解析时间戳弹性搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Elasticsearch的新手,正在尝试创建我的第一个索引,但是在之前工作的timestamp字段存在问题...

I'm new to elasticsearch and am trying to create my first index but am having issues with a timestamp field that was working before...

我这样创建索引:

PUT /kafkasdp
{
  "mappings": {
    "kafka_logs": {
      "properties": {
        "timestamp": {
          "type": "date"
        },
        "log_level": {
          "type": "string"
        },
        "message1": {
          "type": "string"
        },
        "message2": {
          "type": "string"
        }
      }
    }
  }

}

然后我试图发送这样的数据:

and then I'm trying to send data like this:

post /kafkasdp/kafka_logs
{
  "timestamp": "2017-02-03 19:27:20,606",
  "log_level": "INFO",
  "message2": "Deleting segment 1 from log omega-replica-sync-dev-8. (kafka.log.Log)"
}

但继续出现此错误:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse [timestamp]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse [timestamp]",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "Invalid format: \"2017-02-03 19:27:20,606\" is malformed at \" 19:27:20,606\""
    }
  },
  "status": 400
}

我认为我的时间戳记是有效的日期类型吗?

I thought my timestamp is a valid date type?

推荐答案

Read about date type on Elasticsearch reference: you should specify format of date you are expecting in your documents:

PUT your_index_name
{
  "mappings": {
    "your_index_type": {
      "properties": {
        "date": {
          "type":   "date",
          "format": "yyyy-MM-dd HH:mm:ss,SSS"
        }
      }
    }
  }
}

由于您没有指定它,Elasticsearch将期望ISO格式的日期值: yyyyMMdd'T'HHmmss.SSS'Z'(例如, 2017-02-03T19:27:20.606Z )

As you did not specify it, Elasticsearch will expect date value in ISO format: yyyyMMdd'T'HHmmss.SSS'Z' (e.g., 2017-02-03T19:27:20.606Z)

这篇关于无法解析时间戳弹性搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆