Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate negative facets into fq to exclude docs with a given facet value #3093

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mjgiarlo
Copy link
Member

@mjgiarlo mjgiarlo commented Oct 12, 2023

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:

Screenshot from 2023-10-12 16-25-19

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:Tibetan and language_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

…value

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant