watson-developer-cloud / discovery-components

IBM Watson Discovery components
https://watson-developer-cloud.github.io/discovery-components/storybook
Apache License 2.0
22 stars 38 forks source link

feat: update facet filtering logic #495

Closed noah-eigenfeld closed 1 year ago

noah-eigenfeld commented 1 year ago

What do these changes do/fix?

Implementation updates for https://github.ibm.com/Watson-Discovery/disco-issue-tracker/issues/15426

Updates the logic used when compiling a filter string from the selected facets, such that each sub-category of a facet is treated with AND logic instead of combining into ORs for the whole parent category.

How do you test/verify these changes?

  1. Create a project with a set of documents and facets such that several facets will only apply to specific subsets
  2. Test that within a subcategory, fields are filtered as ORs (| when viewing the network query call)
  3. Test that between subcategories, fields are filtered as ANDs (, when viewing the network query call)
  4. Test that fields between an uncategorized facet and a categorized facet still filter as ANDs
    
    Example
    A --- parent category
    B --- sub-category
      C --- term
      D --- term
    E --- sub-category
      F --- term
    G --- parent category
    H --- term

When C and D are selected, the documents returned are the union of C and D documents. When C and F are selected, the documents returned are the intersection of C and F. When C, D, F, and H are selected, the documents returned follow: (C OR D) AND F AND H and so on...


#### Have you documented your changes (if necessary)?
N/A
#### Are there any breaking changes included in this pull request?

<!-- If there are, please ensure that you have included 'BREAKING CHANGE:' at the beginning of the optional body or footer section of the commit that introduces the breaking change. -->