Skip to content

Instantly share code, notes, and snippets.

@bsy
Created August 21, 2009 18:46
Show Gist options
  • Save bsy/172314 to your computer and use it in GitHub Desktop.
Save bsy/172314 to your computer and use it in GitHub Desktop.
search = Sunspot.new_search(Business)
search.build do |s|
s.keywords "#{query} electronics"
s.order_by :name if order == :alpha
s.order_by :review_count, :desc if order == :review_count
s.order_by :stars, :desc if order == :rating
s.paginate :page => page, :per_page => per_page
end
search.query.add_component(OpenStruct.new(:to_params => { :mm => 1 }))
search.execute!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment