Written by The Jahia Team
 
Developers
   Estimated reading time:

This topic has specific details and advanced configuration for the Augmented Search sample UI.

Conditional facets

Conditional facets are facets that display when other facets are selected. For example, you can display a "city facet" when countries are selected in a "country facet". You can use conditional facets to create complex hierarchies and dependencies of facets.

A conditional facet is a JavaScript object where key is name of the facet field (for example jcr:lastModifiedBy) that you want to display based on a condition. value is a function that accepts filters object as a parameter and must return true to display the facet or false not to display the facet. In the example below, the author facet (lastModifiedBy) only displays to a user when they filter by lastModified date.


conditionalFacets: {
    'jcr:lastModifiedBy': filters => filters.filters.some(filter => filter.field === 'jcr:lastModified')
}

Note: The key for a conditional facet object must exactly match the key of the facets objects.