无法解析时间戳弹性搜索

编程入门 行业动态 更新时间:2024-10-26 04:20:39
本文介绍了无法解析时间戳弹性搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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)

更多推荐

无法解析时间戳弹性搜索

本文发布于:2023-11-23 14:49:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹性   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!