Back to Pagy

Get the collection in one of the following ways

docs/toolbox/paginators/meilisearch.md

43.5.31.4 KB
Original Source

:icon-search:  :meilisearch


:meilisearch is a SEARCH paginator designed for Meilisearch results.

=== :icon-tools:  Usage

+++ Active mode

!!!success Pagy searches and paginates You use the pagy_search method in place of the ms_search method. !!!

ruby
extend Pagy::Search
ActiveRecord_Relation.include Pagy::Search # Statically enable pagy_search on the model relations
ruby
# Get the collection in one of the following ways
search = Article.pagy_search(params[:q])
search = Article.pagy_search(params[:q]).results
# Paginate it
@pagy, @response = pagy(:meilisearch, search, **options)

+++ Passive Mode !!!success You search and paginate

Pagy creates its object out of your result. !!!

ruby
# Standard results (already paginated)
@results = Model.ms_search(nil, hits_per_page: 10, page: 10, **options)
# Get the pagy object out of it
@pagy    = pagy(:meilisearch, @results, **options)

+++

!!! Search paginators don't query a DB, but use the same positional technique as :offset paginators, with shared options and readers. !!!

==- :icon-sliders:  Options

search_method: :my_search : Customize the name of the meilisearch method to use (default :ms_search).

{{ include "options/paginator" }}

==- :icon-mention:  Readers

{{ include "snippets/offset-readers" }}

===