lib/mongoid/elasticsearch/response.rb in mongoid-elasticsearch-0.3.8 vs lib/mongoid/elasticsearch/response.rb in mongoid-elasticsearch-0.3.9
- old
+ new
@@ -146,9 +146,14 @@
def multi_without_load
hits.map do |h|
klass = find_klass(h['_type'])
source = h.delete('_source')
+ source.each do |k,v|
+ if v.is_a?(Hash) && v.has_key?("$oid")
+ source[k] = BSON::ObjectId.from_string(v["$oid"])
+ end
+ end
begin
m = klass.new(h.merge(source))
rescue Mongoid::Errors::UnknownAttribute
klass.class_eval <<-RUBY, __FILE__, __LINE__+1
attr_accessor :_type, :_score, :_source