views:

240

answers:

3

Hi,

I'm doing something like this:

Item.find_by_solr('name:ab*')

and it says it returns 297 results:

=> #<ActsAsSolr::SearchResults:0xb6516858 @total_pages=1, @solr_data={:docs=>[doc1, doc2, doc3...]}, :max_score=>1.6935261, :total_pages=>1, :total=>297}, @current_page=1>

Item.count_by_solr('name:ab*') also returns 297.

Yet when iterate it only shows 10 items:

Item.find_by_solr('reference_name:ab*').each do |i| puts i end

I tried adding {:per_page=>80} and :limit=>:all but it still shows those 10. Any idea what I'm missing?

Thanks

A: 

From the Solr FAQ:

How can I get ALL the matching documents back? ... How can I return an unlimited number of rows?

This is impractical in most cases. People typically only want to do this when they know they are dealing with an index whose size guarantees the result sets will be always be small enough that they can feasibly be transmitted in a manageable amount -- but if that's the case just specify what you consider a "manageable amount" as your rows param and get the best of both worlds (all the results when your assumption is right, and a sanity cap on the result size if it turns out your assumptions are wrong)

As for specifying a limit with acts_as_solr, try something like :limit => 80

Mauricio Scheffer
Did you read my question? I said I already tried :limit and :per_page and it didn't work.
Yes I did. You mentioned :per_page=>80 and :limit=>:all but not :limit =><number> Why should I assume that you tried it?
Mauricio Scheffer
A: 

I have in my sketchy notes that you can modify parser_methods.rb, around l. 75 to return only AR ID's, not the objects themselves. Worth a try in large datasets.

Gene T
A: 

as @mausch said Solr (and by extension acts_as_solr) defaults to 10 results. You can use the :limit option to increase this, but it only takes a Fixnum, not the :all symbol. So specify :limit with a Fixnum.

Cody Caughlan