Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store Date Format in elasticsearch

I met a problem when I want to add one datetime string into Elasticsearch.

The document is below:

{"LastUpdate" : "2013/07/24 00:00:00"} 

This document raised an error which is "NumberFormatException" [For input string: \"20130724 00:00:00\"]

I know that I can use the Date Format in Elasticsearch, but I don't know how to use even I read the document on the website.

{"LastUpdate": {     "properties": {         "type": "date",          "format": "yyyy-MM-dd"}     } } 

and

{"LastUpdate": {     "type": "date",      "format": "yyyy-MM-dd"     } } 

are wrong.

How can I transfer the datetime string into date format in Elasticsearch?

How can I store the datetime string directly into Elasticsearch?

like image 780
Jimmy Lin Avatar asked Jul 24 '13 11:07

Jimmy Lin


People also ask

How do I convert string to date in Elasticsearch?

new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"). parse(doc['LAST_ORDER']. value). getTime();

How do I change the date format in Kibana?

Advanced Settingsedit. Advanced Settings control the behavior of Kibana. For example, you can change the format used to display dates, specify the default data view, and set the precision for displayed decimal values. Open the main menu, then click Stack Management > Advanced Settings.


1 Answers

You are nearly there. Set your mapping like this:

{"LastUpdate": {     "type" : "date",     "format" : "yyyy/MM/dd HH:mm:ss"} } 

Read the docs on the date mapping and its options and the date format parameter (one of the options to the date mapping).

Good luck!

like image 54
ramseykhalaf Avatar answered Sep 28 '22 02:09

ramseykhalaf