Pagination with Elasticsearch, Tire, and Kaminari Pagination with Elasticsearch, Tire, and Kaminari elasticsearch elasticsearch

Pagination with Elasticsearch, Tire, and Kaminari


Can you try this??? When I used the per_page option, I had similar issue. So, I shifted to the from size options provided by Tire. I'm not sure what went wrong. But, explicitly setting and using from and size did the trick for me...

class SiteController < ApplicationController  def search    # @results = Painting.search(params[:query])    options = { :page => (params[:page] || 1), :size => 100 }    query = params[:query]    @results = Tire.search ['news','paintings', 'books'], options do      query { string query }      from options[:size].to_i * (options[:page].to_i-1)    end  endend


Tire has method for Will-paginate gem included in its lib so I would prefer that rather than Kaminari gem. If in any case you still want to be with Kaminari, collect the results of tire search.

@results = @results.all.to_hashpaginate @results