Mapping ISO date


(coys) #1

Hello, I have a date stored in mongo as "creationDate" :
ISODate("2012-07-13T19:16:28.962Z").
The mapping created for creationDate is as follows
"creationDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
which is created by default when I store the mongo document in es.

However, the date stored in es is as follows
"creationDate":"2012-07-13T19:16:28.962Z"

As you can see, it is not stored as ISODate..it stipped out the string
part of the date even though I've mapped it as date. Can you please
tell me what I need to change so that it's stored as an ISODate and
not a string

Btw, with the range query I'm still able to enter say
2012-07-13T19:16:28.962Z so I can create a range query on 2 dates
which is cool but I'd still like to store it as say
ISODate("2012-07-13T19:16:28.962Z"). Thanks!


(Jörg Prante) #2

Dates in Elasticsearch are represented in ISO date format, so if you find
"2012-07-13T19:16:28.962Z"" in JSON, it is a valid representation.
Elasticsearch would have reported an error if the date value had been
invalid. Internally, a date is stored as a long.

Best regards,

Jörg

On Friday, July 13, 2012 10:09:24 PM UTC+2, coys wrote:

Hello, I have a date stored in mongo as "creationDate" :
ISODate("2012-07-13T19:16:28.962Z").
The mapping created for creationDate is as follows
"creationDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
which is created by default when I store the mongo document in es.

However, the date stored in es is as follows
"creationDate":"2012-07-13T19:16:28.962Z"

As you can see, it is not stored as ISODate..it stipped out the string
part of the date even though I've mapped it as date. Can you please
tell me what I need to change so that it's stored as an ISODate and
not a string

Btw, with the range query I'm still able to enter say
2012-07-13T19:16:28.962Z so I can create a range query on 2 dates
which is cool but I'd still like to store it as say
ISODate("2012-07-13T19:16:28.962Z"). Thanks!


(system) #3