lib/mebla/result_set.rb in mebla-1.1.11 vs lib/mebla/result_set.rb in mebla-1.1.12
- old
+ new
@@ -28,19 +28,19 @@
model_ids << [model_class]
if model_class.embedded?
model_class_collection = model_ids.assoc(model_class)
# collect parent ids
- # {class => {parent_id => [ids]}}
+ # [class, [parent_id, ids]]
parent_id = hit['_source']['_parent']
model_class_collection << [parent_id]
model_class_collection.assoc(parent_id) << hit['_source']['id']
else
# collect ids
- # {class => [ids]}
+ # [class, ids]
model_ids.assoc(model_class) << hit['_source']['id']
end
end
# Cast the results into their appropriate classes
@@ -50,11 +50,13 @@
model_class = model_class_collection.first
ids = model_class_collection.drop(1)
unless model_class.embedded?
# Retrieve the results from the database
- @entries += model_class.any_in(:_id => ids).entries
+ ids.each do |id|
+ @entries << model_class.find(id)
+ end
else
# Get the parent
parent_class = model_class.embedded_parent
access_method = model_class.embedded_as
@@ -63,10 +65,12 @@
entries_ids = parent_id_collection.drop(1)
parent = parent_class.find parent_id
# Retrieve the results from the database
- @entries += parent.send(access_method.to_sym).any_in(:_id => entries_ids).entries
+ entries_ids.each do |entry_id|
+ @entries << parent.send(access_method.to_sym).find(entry_id)
+ end
end
end
end
Mebla.log("WARNING: Index not synchronized with the database; index total hits: #{@total}, retrieved documents: #{self.count}", :warn) if @total != self.count
\ No newline at end of file