I am using Solr v8 and am looking for a way to selectively include or exclude zero-count facets based on different fields. I would like to exclude zero-count facets that result from my initial base query but include those that are the result of any additional user-applied filters from the UI.
Here's an example of my Solr index:
+----+----------+----------+-------+
| ID | Category | Material | Color |
+----+----------+----------+-------+
| 1 | Tables | Wood | Brown |
| 2 | Tables | Metal | Black |
| 3 | Sofas | Linen | Beige |
| 4 | Sofas | Leather | Brown |
+----+----------+----------+-------+
On browsing the 'Tables' category, I intend to display the facet data as filters, excluding any non-applicable Materials and Colors:
MATERIAL
[ ] Wood (1)
[ ] Metal (1)
COLOR
[ ] Brown (1)
[ ] Black (1)
+----+----------+----------+-------+
| RESULT |
| ID | Category | Material | Color |
+----+----------+----------+-------+
| 1 | Tables | Wood | Brown |
| 2 | Tables | Metal | Black |
+----+----------+----------+-------+
However, on applying additional filters such as Material=Wood, I want to continue displaying zero-count Colors that were excluded due to the new filter but hide those excluded by the category filter:
MATERIAL
[X] Wood (1)
[ ] Metal (1)
COLOR
[ ] Brown (1)
Black (0) (unselectable)
+----+----------+----------+-------+
| RESULT |
| ID | Category | Material | Color |
+----+----------+----------+-------+
| 1 | Tables | Wood | Brown |
+----+----------+----------+-------+
(Note: Material is a multi-select filter with tagging.)
This older question didn't provide a clear solution: Offer facets with zero count for certain category with min count set to one using Solr - I tried to facet the Material twice, once excluding the category tag and once without, like so: facet.field={!ex=cat_tag,mat_tag}material&facet.field={!ex=mat_tag}material
, but the outputs didn't provide enough information to determine when to hide or show specific zero-count facets.
Is there a way to achieve this, either through a query command or some form of pre/post-processing? Thanks in advance.