I have setup faceted search using Sunspot, SOLR. Like this:
for row in @search.facet(:facet_id).rows
link_to row.instance.name, :url_for(:search => params[:q], :facet_id => row.value)
My issue is that when I execute the faceted search in the controller like this:
@search = Sunspot.search(MyModel) do
keywords search_text
facet :facet_id
with(:facet_id, params[:facet_id]) if params[:facet_id].present?
end
The facet counts are now calculated based on the with(:facet_id, params[:facet_id]) condition. I want the facet counts to ALWAYS be calculated without this condition.
Do I need to execute two searches? One for the search without the conditions (to calculate the facet counts) and one with the condition to retrieve the results. Or is there a way to do this in one SOLR query.
Thanks
Hamish