Translate negative facets into fq to exclude docs with a given facet value #3093
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: