#
#
:elasticsearch_rails
:elasticsearch_rails
is a paginator for ElasticsearchRails
response objects.
Pagy searches and paginate
You use the pagy_search
method in place of the search
method.
Model
extend Pagy::Search
Controller
# Get the search in one of the following ways
search = Article.pagy_search(params[:q])
search = Article.pagy_search(params[:q]).records
search = Article.pagy_search(params[:q]).results
# Paginate it
@pagy, @response = pagy(:elasticsearch_rails, search, **options)
You search and paginate
Pagy creates its object out of your result.
Controller
# Standard response (already paginated)
@response = Article.search('*', from: 0, size: 10, ...)
# Get the pagy object out of it
@pagy = pagy(:elasticsearch_rails, @response, **options)
Search paginators don't query a DB, but use the same positional technique as :offset paginators, with shared options and readers.
search_method: :my_search
- Customize the name of the search method (default
:search
)
- Customize the name of the search method (default
See also Offset Options
See Offset Readers