All results from Solr are paginated... By default, Sunspot requests the first 30 results from Solr. In your example, you're paginating the array of the first 30 results returned by Solr.
I find it easiest to just call paginate
in the search blocks in my controllers...
@search = Sunspot.search(BlogPost) do
# filters...
paginate(page: params[:page], per_page: 10)
end
Then use Kaminari's paginate helper in my views...
<%= paginate @search.results %>
* you could use @search.hits
if you don't want to load model instances
Alternatively, it looks like you can pass in :total_count
as a keyword argument to Kaminari's paginate_array
method. So this should work if you want to stick with the method you're using above...
Kaminari.paginate_array(search.results, total_count: search.total).page(params[:page]).per(10)