Skip to content

Commit

Permalink
added raw_response method check for pagy_elastisearch_rails (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed May 8, 2020
1 parent 7a09bb9 commit d571719
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pagy/extras/elasticsearch_rails.rb
Expand Up @@ -28,7 +28,7 @@ def pagy_elasticsearch_rails(pagy_search_args, vars={})
search_args[-1][:size] = vars[:items]
search_args[-1][:from] = vars[:items] * (vars[:page] - 1)
response = model.search(*search_args)
total = response.raw_response['hits']['total']
total = response.respond_to?(:raw_response) ? response.raw_response['hits']['total'] : response.response['hits']['total']
vars[:count] = total.is_a?(Hash) ? total['value'] : total
pagy = Pagy.new(vars)
# with :last_page overflow we need to re-run the method in order to get the hits
Expand Down

0 comments on commit d571719

Please sign in to comment.