This commit is a rough first hack at adding the ability to filter out docs from a result set that match a facet value. For instance, all docs with language_ssim:Tibetan excluding those with language_ssim:English. None of the UI work to support this is included in this commit, which is more to get familiar (once again) with Solr and Blacklight. There is probably a better way to handle this BL query args-to-Solr query translation than injecting { exclude: true } into facet values and sniffing for it. Pushing this commit up for early feedback to come up with a solid approach before tackling UI work or tests.
Here's what the UI looks like with the current code changes:
You can see there are 5 search results, which is correct, since 6 docs have language_ssim:Tibetan and 1 doc has both language_ssim:Tibetanandlanguage_ssim:English. That latter doc is what we're filtering out by changing f[language_ssim]=English to f[-language_ssim]=English in the URL. That the inclusive filters UI is loading is unintended, and likely because of how I'm stuffing the facet value (English) into an array with a hash ({ exclude: true }) in FilterField#values to make sure FilterField#add, FilterField#remove, and FilterField#include are aware of this behavior, and ultimately so that SearchBuilderBehavior#facet_value_to_fq_string (via SearchBuilderBehavior#add_facet_fq_to_solr) knows to prepend a - in front of the Solr FQ query arg for language = English in this example.
Once I get some feedback on this approach, the to-dos are:
[ ] Iterate on the current approach based on feedback
[ ] Implement a UI design (like this example) so that URL hacking is no longer required
[ ] Determine if this feature should be on by default or opt-in only, and whether it should apply for all facets or select ones
This commit is a rough first hack at adding the ability to filter out docs from a result set that match a facet value. For instance, all docs with
language_ssim:Tibetan
excluding those withlanguage_ssim:English
. None of the UI work to support this is included in this commit, which is more to get familiar (once again) with Solr and Blacklight. There is probably a better way to handle this BL query args-to-Solr query translation than injecting{ exclude: true }
into facet values and sniffing for it. Pushing this commit up for early feedback to come up with a solid approach before tackling UI work or tests.Here's what the UI looks like with the current code changes:
You can see there are 5 search results, which is correct, since 6 docs have
language_ssim:Tibetan
and 1 doc has bothlanguage_ssim:Tibetan
andlanguage_ssim:English
. That latter doc is what we're filtering out by changingf[language_ssim]=English
tof[-language_ssim]=English
in the URL. That the inclusive filters UI is loading is unintended, and likely because of how I'm stuffing the facet value (English
) into an array with a hash ({ exclude: true }
) inFilterField#values
to make sureFilterField#add
,FilterField#remove
, andFilterField#include
are aware of this behavior, and ultimately so thatSearchBuilderBehavior#facet_value_to_fq_string
(viaSearchBuilderBehavior#add_facet_fq_to_solr
) knows to prepend a-
in front of the Solr FQ query arg for language = English in this example.Once I get some feedback on this approach, the to-dos are: