Module: Elasticsearch::FacetedSearch::Pagination

Included in:
FacetBase
Defined in:
lib/elasticsearch/faceted_search/pagination.rb

Instance Method Summary collapse

Instance Method Details

#current_pageObject



22
23
24
# File 'lib/elasticsearch/faceted_search/pagination.rb', line 22

def current_page
  (search_params[:page] ||= 1).to_i
end

#limitObject



18
19
20
# File 'lib/elasticsearch/faceted_search/pagination.rb', line 18

def limit
  (search_params[:limit] ||= 32).to_i
end

#limit_valueObject



14
15
16
# File 'lib/elasticsearch/faceted_search/pagination.rb', line 14

def limit_value
  limit
end

#total_countObject



4
5
6
7
8
# File 'lib/elasticsearch/faceted_search/pagination.rb', line 4

def total_count
  search['hits']['total'].to_i
rescue
  0
end

#total_pagesObject



10
11
12
# File 'lib/elasticsearch/faceted_search/pagination.rb', line 10

def total_pages
  (total_count.to_f / limit_value.to_f).ceil
end