I'm using Solr via Sunspot for rails, but I can't figure out how to return more than 30 results?
Say I have this block for search开发者_运维百科:
posts = Post.search do
keywords('something')
end
How would I establish that sunspot should return all of the matches, not just 30?
You can use paginate
:
posts = Post.search do
keywords 'something'
paginate :page => 1, :per_page => 100
end
To change the default number of results add the following to application.rb
or its own initializer file.
Sunspot.config.pagination.default_per_page = 30
Source
To clarify, Solr always paginates results -- 30 is an arbitrary default, but there is always a page length. If you want all the results, you can either set a very high page length, or page through the results in your code to compose an array with all the results (the latter probably being preferable).
You can also modify your solr configuration as stated here: http://solr.pl/en/2011/01/10/optimization-query-result-window-size/
精彩评论