I have an indexed field defined as :date
that is a method to determine which DateTime
object to store.
settings index: { number_of_shards: 1 } do
mapping do
...
indexes :date, index: :not_analyzed, type: 'date'
...
end
end
And in my as_indexed_json
I have it listed under :methods
def as_indexed_json(options = {})
self.as_json(
...
methods: [:full_text, :tag_list, :category_list, :date, :month, :year],
...
)
end
It properly indexes the desired value as "date": "2016-05-19T09:43:09-04:00"
but when I read the value after searching, the date comes back as class String
instead of any of the date classes.
I have fiddled with some of the available format
values on that field such as date_time_no_millis
, strict_ date_time_no_millis
, and "yyyy-MM-dd'T'HH:mm:ssZ"
, but it appears that that only adjusts the setting and understanding of the value, rather than the reading and class hydration of them.
How can I get this date
value to read back as a Rails DateTime
as it exists in my DB?
Previously posted as a Github Issue with no response.