# Meilisearch Extra

In 

Paginate Meilisearch results.

# Setup

pagy.rb (initializer)
require 'pagy/extras/meilisearch'

# Modes

This extra offers two ways to paginate Meilisearch objects:

# Usage


Model
extend Pagy::Meilisearch
ActiveRecord_Relation.include Pagy::Meilisearch  
Controller (pagy_search)
# get the collection in one of the following ways
collection = Article.pagy_search(params[:q])
collection = Article.pagy_search(params[:q]).results
# paginate it
@pagy, @response = pagy_meilisearch(collection, items: 10)

# Usage


Controller (Search)
@results = Model.ms_search(nil, hits_per_page: 10, page: 10, ...)
@pagy    = Pagy.new_from_meilisearch(@results, ...)

# Files

# Variables

Variable Description Default
:meilisearch_pagy_search customizable name of the pagy search method :pagy_search
:meilisearch_search customizable name of the original search method :ms_search

# Methods

This method accepts the same arguments of the ms_search method and you must use it in its place in active mode.

This constructor accepts a Meiliserch object, plus the optional pagy variables. It automatically sets the :items, :page and :count pagy variables extracted/calculated out of it.

This method is similar to the generic pagy method, but specialized for Meilisearch. (see the pagy doc)

It expects to receive YourModel.pagy_search(...) result and returns the paginated response.

This sub-method is similar to the pagy_get_vars sub-method, but it is called only by the pagy_meilisearch method. (see the pagy_get_vars doc).