Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sunspot solr search, how to return all records at once?

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.

like image 551
Bijendra Avatar asked Dec 29 '11 10:12

Bijendra


1 Answers

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
like image 84
jhdavids8 Avatar answered Nov 20 '22 12:11

jhdavids8