Skip to content

Commit

Permalink
Cast field data that is wrapped in an array from elasticsearch v1
Browse files Browse the repository at this point in the history
Elasticsearch v1 returns field values as an array when using `fields` option.

elastic/elasticsearch#4542
  • Loading branch information
esmarkowski committed Mar 13, 2014
1 parent 0512cc5 commit 4c09793
Showing 1 changed file with 3 additions and 0 deletions.
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)
klass = self.class.property_types[name.to_sym]
# elasticsearch v1 returns field data wrapped in an array
value = value.first unless klass.is_a?(Array) || value.nil? || !value.is_a?(Array)
case

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

0 comments on commit 4c09793

Please sign in to comment.