Date format


(Andrew Degtiariov) #1

I have dates like this '2010-08-09T11:13:04+0300' and trying to add
ones to mapping:
...
"created" : {
"type" : "date",
"format": "date_time_no_millis"
}
...

But elasticsearch rejected index of documents with following error:
IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is
malformed at "+0300"]

Which format I should use? I can normalize all dates to UTC (I don't
need time zone in dates) but don't see proper format in documentation.

--
Andrew Degtiariov
DA-RIPE


(John Merrells) #2

I had a similar problem. I solved it by providing a mapping for my documents with a custom format for the date... e.g.

...
"publication_date" : {
"index" : "not_analyzed",
"type" : "date",
"format" : "yyyy/MM/dd HH:mm:ss Z"
},
...

John

On Aug 9, 2010, at 7:58 AM, Andrew Degtiariov wrote:

I have dates like this '2010-08-09T11:13:04+0300' and trying to add
ones to mapping:
...
"created" : {
"type" : "date",
"format": "date_time_no_millis"
}
...

But elasticsearch rejected index of documents with following error:
IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is
malformed at "+0300"]

Which format I should use? I can normalize all dates to UTC (I don't
need time zone in dates) but don't see proper format in documentation.

--
Andrew Degtiariov
DA-RIPE


(John Merrells) #3

Date formatting...

http://www.elasticsearch.com/docs/elasticsearch/mapping/date_format/

http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html

John

On Aug 9, 2010, at 7:58 AM, Andrew Degtiariov wrote:

I have dates like this '2010-08-09T11:13:04+0300' and trying to add
ones to mapping:
...
"created" : {
"type" : "date",
"format": "date_time_no_millis"
}
...

But elasticsearch rejected index of documents with following error:
IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is
malformed at "+0300"]

Which format I should use? I can normalize all dates to UTC (I don't
need time zone in dates) but don't see proper format in documentation.

--
Andrew Degtiariov
DA-RIPE


(Andrew Degtiariov) #4

2010/8/9 John Merrells merrells@gmail.com:

I had a similar problem. I solved it by providing a mapping for my documents with a custom format for the date... e.g.

...
"publication_date" : {
"index" : "not_analyzed",
"type" : "date",
"format" : "yyyy/MM/dd HH:mm:ss Z"
},
...

John

Thank you!

Here my updated mapping for my object:
...
"created" : {
"type" : "date",
"index" : "not_analyzed",
"format" : "yyyy-MM-dd'T'HH:mm:ssZ"
}
...

--
Andrew Degtiariov
DA-RIPE


(system) #5