Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Cast field data that is wrapped in an array from elasticsearch v1 #947

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/tire/model/persistence/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def __update_attributes(attributes)
# instances and automatically convert UTC formatted strings to Time.
#
def __cast_value(name, value)
default = self.class.property_defaults[name.to_sym]
# elasticsearch v1 returns field data wrapped in an array
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Elasticsearch 1.x

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add the link to elastic/elasticsearch#4542 as well?

value = value.first unless !value.is_a?(Array) || default.is_a?(Array) || value.nil?
case

when klass = self.class.property_types[name.to_sym]
Expand Down