弹性搜索字段类型“日期”插入日期(“Y-m-d H:i:s”)

时间:2022-01-22 21:31:11

I´m trying to insert a datetime value into my Es index. But i don´t understand it right at the moment.

我´试图插入一个datetime值我Es指数。´但我不理解它。

If I do a custom mapping with e.g. "eventDate" => "date" and try to index a doc with "eventDate" => date('Y-m-d H:i:s') i get this error:

如果我用例做一个自定义映射。“eventDate”=>“date”,并尝试用“eventDate”=>日期(“Y-m-d H:i:s”)来索引doc,我得到了这个错误:

IllegalArgumentException[Invalid format: \"2014-03-13 15:36:15\" is malformed at \" 15:36:15\"]; ","status":400}

(无效格式:\“2014-03-13 15:36:15\”在\“15:36:15\”中出现);”、“地位”:400 }

I understand that, but I don´t know what i should change ?!?! I wanna use that field in Kibana histogram later on, so it must be a date field.

我理解,但我不知道我应该改变什么?!?!我想以后在Kibana直方图上使用这个字段,所以它必须是一个日期字段。

In Es docs I saw the date-format like this: "Y-m-dTH:i:s" ! What does this "T" in the middle ?? And how can I index this exactly like this ?

在Es文档中,我看到了这样的数据格式:“Y-m-dTH: I:s”!中间的T是什么?我怎么能把它标出来呢?

Thanks für your help. marc

由于毛你的帮助。马克

1 个解决方案

#1


1  

The T is simply a delimiter of the date. You can read more information about this in Wikipedia:

T只是日期的分隔符。你可以在*上看到更多关于这个的信息:

A single point in time can be represented by concatenating a complete date expression, the letter T as a delimiter, and a valid time expression. For example "2007-04-05T14:30". If a time zone designator is required, it follows the combined date and time. For example "2007-04-05T14:30Z" or "2007-04-05T12:30-02:00".

一个时间点可以通过连接一个完整的日期表达式、字母T作为分隔符和有效的时间表达式来表示。例如“2007 - 04 - 05 t14:30”。如果需要时区指示符,则它遵循组合日期和时间。例如“2007-04-05T14:30Z”或“2007-04-05T12:30-02:00”。

Either basic or extended formats may be used, but both date and time must use the same format. The date expression may be calendar, week, or ordinal, and must use a complete representation. The time expression may use reduced accuracy. It is permitted to omit the 'T' character by mutual agreement.

可以使用基本的或扩展的格式,但日期和时间必须使用相同的格式。日期表达式可以是日历、星期或序数,并且必须使用完整的表示形式。时间表达式可以使用较低的精度。经双方同意,可以省略“T”字。

And for the indexing error, try to put the T delimiter and also the timezone (you can just put Z, that means UTC). After that you should be able to plot graphs in Kibana.

对于索引错误,尝试将T分隔符和时区(你可以放Z,也就是UTC)。之后你就可以在基巴纳绘制图表了。

#1


1  

The T is simply a delimiter of the date. You can read more information about this in Wikipedia:

T只是日期的分隔符。你可以在*上看到更多关于这个的信息:

A single point in time can be represented by concatenating a complete date expression, the letter T as a delimiter, and a valid time expression. For example "2007-04-05T14:30". If a time zone designator is required, it follows the combined date and time. For example "2007-04-05T14:30Z" or "2007-04-05T12:30-02:00".

一个时间点可以通过连接一个完整的日期表达式、字母T作为分隔符和有效的时间表达式来表示。例如“2007 - 04 - 05 t14:30”。如果需要时区指示符,则它遵循组合日期和时间。例如“2007-04-05T14:30Z”或“2007-04-05T12:30-02:00”。

Either basic or extended formats may be used, but both date and time must use the same format. The date expression may be calendar, week, or ordinal, and must use a complete representation. The time expression may use reduced accuracy. It is permitted to omit the 'T' character by mutual agreement.

可以使用基本的或扩展的格式,但日期和时间必须使用相同的格式。日期表达式可以是日历、星期或序数,并且必须使用完整的表示形式。时间表达式可以使用较低的精度。经双方同意,可以省略“T”字。

And for the indexing error, try to put the T delimiter and also the timezone (you can just put Z, that means UTC). After that you should be able to plot graphs in Kibana.

对于索引错误,尝试将T分隔符和时区(你可以放Z,也就是UTC)。之后你就可以在基巴纳绘制图表了。