Module: Pagy::ElasticsearchRailsExtra

Defined in:
lib/pagy/extras/elasticsearch_rails.rb

Overview

Paginate ElasticsearchRails response objects

Defined Under Namespace

Modules: Backend, ElasticsearchRails, Pagy

Class Method Summary collapse

Class Method Details

.total_count(response) ⇒ Object

Get the count from different version of ElasticsearchRails



13
14
15
16
17
18
19
20
# File 'lib/pagy/extras/elasticsearch_rails.rb', line 13

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