sunspot/sunspot — pull request #289 by pduey (2012-09-19 14:13:18+00:00)
Title: Mark selected facets

The is a re-request of a closed pull request (https://github.com/sunspot/sunspot/pull/41). I made changes per comments from @nz.

I added a "selected" method on the FacetRow. I determine which facets are selected by inspecting the solr responseHeader in AbstractSearch, called from FieldFacet. In AbstractSearch I created the fq_response method which exposes all the values in responseHeader.params.fq as a Hash. If the hash key ends in '_im' or '_s', then I further split the hash value into an array.

For example:
fq: [
"type:VenueOffering"
"amenities_ids_im:(9 AND 12)"
"neighborhood_s:(East\ Village OR Chelsea)"
"capacity_max_is:[30 TO *]"
]

becomes
fq_response: ["type" => "VenueOffering", "amenties_ids_im" => ["9", "12"], "neighborhood_s" => ["East Village", "Chelsea"], "capacity_max_is" => "[30 TO *]"]