Mapped date field returned as string?

Are date mapped fields not converted to java.lang.Date objects?

I search for a document that has one field mapped to a date
"properties" : {
"_value" : {
"format" : "dateOptionalTime",
"type" : "date"
},

When I look at the source of the document that was returned as a
search hit the object type of the field value is a java.lang.String
instead of a java.lang.Date. I guess I was expecting date fields to be
converted to java.util.Date. The integers, booleans, etc appear to be
returned as the appropriate java objects (Integer, Boolean, etc). An
example string returned for a "date" mapped field was
"2011-04-12T19:18:41.172Z". Is this expected? Is it not converted to a
Date since the mapping specifies the format? Is there a way for it to
return a date object (e.g. - if i specify a specific format)? Just
hoping to avoid having to store meta data in the source to track date
fields (so I know to load to a Date object) since my mapping already
does that.

Thanks,
Bob

Heya,

No, they are not converted to Dates, though its quite simple to convert it yourself (and use Joda, not the horror that is java.util.Date and friends). The reason for that is that it follows more closely the json data model. In general, it could have been done.

-shay.banon
On Tuesday, April 12, 2011 at 10:52 PM, Bob wrote:

Are date mapped fields not converted to java.lang.Date objects?

I search for a document that has one field mapped to a date
"properties" : {
"_value" : {
"format" : "dateOptionalTime",
"type" : "date"
},

When I look at the source of the document that was returned as a
search hit the object type of the field value is a java.lang.String
instead of a java.lang.Date. I guess I was expecting date fields to be
converted to java.util.Date. The integers, booleans, etc appear to be
returned as the appropriate java objects (Integer, Boolean, etc). An
example string returned for a "date" mapped field was
"2011-04-12T19:18:41.172Z". Is this expected? Is it not converted to a
Date since the mapping specifies the format? Is there a way for it to
return a date object (e.g. - if i specify a specific format)? Just
hoping to avoid having to store meta data in the source to track date
fields (so I know to load to a Date object) since my mapping already
does that.

Thanks,
Bob

Thanks, Shay. I just included some meta data to mark that the String
is really a date, and used joda time to convert it to a date object.
Easy sneezy.

Thanks,
Bob

On Apr 12, 3:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Heya,

No, they are not converted to Dates, though its quite simple to convert it yourself (and use Joda, not the horror that is java.util.Date and friends). The reason for that is that it follows more closely the json data model. In general, it could have been done.

-shay.banon

On Tuesday, April 12, 2011 at 10:52 PM, Bob wrote:

Are date mapped fields not converted to java.lang.Date objects?

I search for a document that has one field mapped to a date
"properties" : {
"_value" : {
"format" : "dateOptionalTime",
"type" : "date"
},

When I look at the source of the document that was returned as a
search hit the object type of the field value is a java.lang.String
instead of a java.lang.Date. I guess I was expecting date fields to be
converted to java.util.Date. The integers, booleans, etc appear to be
returned as the appropriate java objects (Integer, Boolean, etc). An
example string returned for a "date" mapped field was
"2011-04-12T19:18:41.172Z". Is this expected? Is it not converted to a
Date since the mapping specifies the format? Is there a way for it to
return a date object (e.g. - if i specify a specific format)? Just
hoping to avoid having to store meta data in the source to track date
fields (so I know to load to a Date object) since my mapping already
does that.

Thanks,
Bob

would you mind to post the code of your solution