Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby: Wrapper for acts_as_solr results that behaves/feels like will_paginate collection
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
Gemfile
Gemfile.lock
Rakefile
Readme.md
VERSION
init.rb
solr_collection.gemspec

Readme.md

  • 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)

Usage

  • As Rails plugin rails plugin install git://github.com/grosser/solr_collection.git
  • As gem sudo gem install solr_collection

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

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

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')

Author

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.