lib/mongoid/elasticsearch/response.rb in mongoid-elasticsearch-0.5.0 vs lib/mongoid/elasticsearch/response.rb in mongoid-elasticsearch-0.5.1
- old
+ new
@@ -149,10 +149,11 @@
end
def multi_without_load
hits.map do |h|
klass = find_klass(h['_type'])
+ h[:_highlight] = h.delete('highlight') if h.key?('highlight')
source = h.delete('_source')
if defined?(Moped::BSON)
source.each do |k,v|
if v.is_a?(Hash) && v.has_key?("$oid")
source[k] = Moped::BSON::ObjectId.from_string(v["$oid"])
@@ -172,10 +173,10 @@
else
m.id = BSON::ObjectId.from_string(h['_id'])
end
rescue Mongoid::Errors::UnknownAttribute
klass.class_eval <<-RUBY, __FILE__, __LINE__+1
- attr_accessor :_type, :_score, :_source
+ attr_accessor :_type, :_score, :_source, :_highlight
RUBY
m = klass.new(h.merge(source))
end
m.new_record = false
m