module Pagy::ElasticsearchRailsExtra

def total_count(response)

Get the count from different version of ElasticsearchRails
def total_count(response)
  total = if response.respond_to?(:raw_response)
            response.raw_response['hits']['total']
          else
            response.response['hits']['total']
          end
  total.is_a?(Hash) ? total['value'] : total
end