I am using solr via sunspot in my rails application where I need to return more than 30 records which is set by default. I can do it as told in Sunspot solr but i don't want pagination for the data. I want to display all the data in a single page irrespective of rows. Also providing a hard coded value is not a probable solution which I'm looking for.
Sunspot solr search, how to return all records at once?
Asked Answered
Solr always paginates, so it looks like there's no way to disable pagination through Sunspot (https://groups.google.com/forum/#!topic/ruby-sunspot/kVKfsrDpokc). The only thing I can think to do is get the number of records for your model before the search, and then set the per_page variable to that number so you're guaranteed to only return one page. Something like this:
count = Service.count
@search = Service.search do
keywords(params[:search])
paginate :page => 1, :per_page => count
end
yaa .. i had thought the same and kept the option for last but had to implement as could not get any other soln. –
Normi
be careful. yet
per_page: 10**10
gives an error (exceeding maximum, i guess), so it is possible to use static per_page: 10**9
for example instead of Service.count
each time –
Hill Execute twice the query Service.search(....).total and pass the total as per page argument –
Dyandyana
© 2022 - 2024 — McMap. All rights reserved.