Skip to content

Commit d3e5c8b

Browse files
committed
[MODEL] Added, that each_with_hit and map_with_hit in Elasticsearch::Model::Response::Records call to_a
The `zip` method in `records.rb` didn't call `to_a` on the collection, thus the records were not returned in the same order as Elasticsearch's results. Related #99 Related #102
1 parent 9bbeadd commit d3e5c8b

File tree

1 file changed

+2
-2
lines changed
  • elasticsearch-model/lib/elasticsearch/model/response

1 file changed

+2
-2
lines changed

elasticsearch-model/lib/elasticsearch/model/response/records.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ def results
4343
# Yields [record, hit] pairs to the block
4444
#
4545
def each_with_hit(&block)
46-
records.zip(results).each(&block)
46+
records.to_a.zip(results).each(&block)
4747
end
4848

4949
# Yields [record, hit] pairs and returns the result
5050
#
5151
def map_with_hit(&block)
52-
records.zip(results).map(&block)
52+
records.to_a.zip(results).map(&block)
5353
end
5454

5555
# Delegate methods to `@records`

0 commit comments

Comments
 (0)