Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created September 9, 2011 21:48
Show Gist options
  • Save brandon-beacher/1207419 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1207419 to your computer and use it in GitHub Desktop.
@search = Sunspot.search(KarastanCarpet) do |search|
search.keywords(params[:keywords]) if params[:keywords].present?
search.with(:effective_brand, KarastanCarpet.brand_for_dealer(@dealer))
search.with(:color_category_names).any_of(
params[:color_category_names] ) if params[:color_category_names].present?
search.with(:fiber_name).any_of(
params[:fiber_names] ) if params[:fiber_names].present?
search.with(:style_names).any_of(
params[:style_names] ) if params[:style_names].present?
search.without(:id,
@dealer_catalog.custom_search_params[:id_not_in]) if @dealer_catalog && @dealer_catalog.custom_search_params[:id_not_in].present?
search.facet(:color_category_names)
search.facet(:style_names)
search.facet(:fiber_name)
search.order_by(:color_category_names_count, :desc)
search.paginate(:page => params[:page], :per_page => 10)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment