Default category value for facets

A client has requested that when a result’s facet doesn’t match a particular category (i.e. the value is blank/empty/missing), it should still show up when the user selects an arbitrary category.

e.g. there’s a ‘Region’ facet, with possible values ‘National’, ‘North’, ‘South’, ‘West’ and ‘Overseas’. Some results don’t have a value. If a user selects ‘National’, they should also see the results that don’t contain a value. If they select any of the other categories, then they should only see the results matching those categories.

Using faceted nav v2, so they can select multiple categories for that facet.

Is it possible to just tack on a &f.Region|region= (i.e. blank value) and have that work? Preferably without that showing up in the selected facets…

I think the client wants to avoid having to explicitly set a value of ‘National’ to everything that currently doesn’t have one.

It sounds as though the default ‘All’ label used by faceted navigation simply needs to be renamed to ‘National’ here.

Default output when selecting a region would render similar to:

Region > All > North

The ‘All’ link text is clickable, and removes the North constraint (and the corresponding URL parameter).

Region > National seems like default logic being processed, but adding it to the UI is the intent:

Region: [x] National [ ] North [ ] South [ ] East [ ] West
If a user checks any item other than ‘National’, the ‘National’ checkbox would need to be deselected.

Region: [ ] National [x] North [ ] South [x] East [ ] West
Conversely, if a user has selected one or more non-National categories, these could need deselecting when selecting ‘National’ again (depending on the desired logic).

An alternative approach may be to use query gscopes (new in v15.8+) combined with gscope facets:

# query-gscopes.cfg
1 region:north
2 region:south
3 region:east
4 region:west
# National region - anything that's doesn't have a region defined as north, south, east or west
5 ![region:north region:south region:east region:west]

How would one rename the ‘all’ label if using v2 faceted nav & checkboxes?

Also, correct me if I’m wrong, but if ‘National’ was just renamed from ‘All’ here, wouldn’t it also include anything with North, South, West or Overseas?

And I don’t know if I could use the query gscopes in the way you suggested, because a result might have one of the regions in addition to National.

So really I need to be able to facet by region:national or region:[blank]

Hmm, you’re trying to solve what is really a data deficiency at query-time. Can you not use a filter during gathering to detect the absence of any value in the metadata and setting it to national? In that case, your metadata is all correct at query time and no trickery is needed.

So, fun fact, you can do this: &f.Region|region=National&f.Region|region=*

Had to do a bit to ensure that gets added and removed where necessary, but it works exactly how the client was requesting (results without a value for that metadata field should be displayed when National is checked, but not labelled with National