Reputation: 73
I have several categories of facets I'm looking for and in one I want, when the user clicks more than one filter in that particular category, to have the results sunspot returns include everything that matches either of the choices, not only both. I tried this:
@search = ProfileSearch.new(search_params) do
facet_restriction = with(:grad_year,params[:grad_year])
facet(:grad_year, :exclude => facet_restriction)
end
But that doesn't seem to be working at all? Am I not using multiselect facets in the appropriate way or should I be looking at doing something entirely different?
Any thoughts would be appreciated.
Upvotes: 1
Views: 55
Reputation: 1
I do something like this:
grad_year_exclusions = []
if params[:grad_year].present?
grad_year_exclusions << with(:grad_year).any_of(params[:grad_year])
end
grad_year_exclusions.compact!
grad_year_exclusions = nil if grad_year_exclusions.empty?
facet(:grad_year, exclude: grad_year_exclusions)
(params[:grad_year] being an array)
Hope this helps.
Upvotes: 0
Reputation: 33542
I think it should be
@search = ProfileSearch.search(search_params) do
facet_restriction = with(:grad_year,params[:grad_year])
facet(:grad_year, :exclude => facet_restriction)
end
Upvotes: 1