Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (22 sloc) 1.06 KB
  • Wrap acts_as_solr results to behave like WillPaginate (use same helpers!)
  • Make arrays behave like solr results (e.g. mock an empty result when solr is down or throws errors)


  • As Rails plugin rails plugin install git://
  • As gem sudo gem install solr_collection

Example: options = {:limit=>10, :offset=>100, :facets=>{....}, .... } results = MyModel.find_by_solr("abc", options) rescue [] results =, options.slice(:limit, :offset))

do_something if results.facets
do_something if results.total_entries > results.size # more pages ?

Other features: #facet fields can be nil or [] or {} -> use has_facet_fields? to check puts results.facets['facet_fields']['category_id_facet'] if results.has_facet_fields? puts results.facet_field('category_id_facet')


Michael Grosser
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.