eikes/facetedsearch — pull request #2 by brockfanning (2013-09-08 16:30:34+00:00)
Title: Change behavior of multiple filters within a single facet

The current behavior for multiple filters in a single facet is not what I would expect. The result set is a union of the active filters, instead of an intersection. For example in the demo, if I click on "Erlang", I see 9 results as advertised. The "Lisp" filter than advertises that it has only 1 result, since there is only 1 item that is tagged both "Erlang" and "Lisp". So far this is what I would expect. But if I click on "Lisp", the result set now includes 15 items, and the "Lisp" filter count changes to 7.

The behavior I was expecting was 1 item in the result set, and both "Erlang" and "Lisp" counts changing to 1. This is actually the behavior when selecting multiple filters across different facets, so I was thinking that it should probably work the same for multiple filters in a single facet. This is especially important for sites that have only one facet, like a single "tags" taxonomy or something.

My patch changes this behavior. It also removes the code that was changing all zero-counts into plus-signs, since now the "0" actually makes sense. However, the displaying of the empty filters is essentially useless, since clicking on it only reduces the search results to 0. So I've added an option to hide empty filters, and set its default to true.

Thanks for a great script, and hope this is helpful!