Skip to content

Commit 93a0da0

Browse files
authored
[MODEL] Avoid executing search twice; Reuse response in Response#raw_response (#850)
1 parent 5067eda commit 93a0da0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def timed_out
6060
# Returns the statistics on shards
6161
#
6262
def shards
63-
@shards ||= HashWrapper.new(raw_response['_shards'])
63+
@shards ||= response['_shards']
6464
end
6565

6666
# Returns a Hashie::Mash of the aggregations
@@ -76,7 +76,7 @@ def suggestions
7676
end
7777

7878
def raw_response
79-
@raw_response ||= search.execute!
79+
@raw_response ||= @response ? @response.to_hash : search.execute!
8080
end
8181
end
8282
end

0 commit comments

Comments
 (0)