我是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?
推荐答案在 Elasticsearch参考:您应在文档中指定期望的日期格式:
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)
更多推荐
无法解析时间戳弹性搜索
发布评论