2

When retrieving results from ES using Chewy, the date-typed results are returned as Ruby strings.

My index is defined just like:

class OrdersIndex < Chewy::Index
  define_type Order do

    field :id, type: "keyword"
    field :created_at, type: "date"
  end
end

When the results are retrieved:

OrdersIndex.order(created_at: :desc).first.created_at.class
# => String

Is there a way to deserialize this date field in a Ruby date object automatically, without having to explicitly map the results using Time#parse?

vinibrsl
  • 6,563
  • 4
  • 31
  • 44

0 Answers0