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.
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.
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.