Marc
Marc

Reputation: 3

ElasticSearch Field Type "date" inserting date('Y-m-d H:i:s')

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

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:

IllegalArgumentException[Invalid format: \"2014-03-13 15:36:15\" is malformed at \" 15:36:15\"]; ","status":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.

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 ?

Thanks für your help. marc

Upvotes: 0

Views: 990

Answers (1)

Pigueiras
Pigueiras

Reputation: 19356

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

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".

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.

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.

Upvotes: 1

Related Questions