Hide a facet that does not affect the result


yet another question from me about a feature, that I am used to working with a competitor’s product :slight_smile:

Is there a way to automatically hide any facet that will not change the results page? For example: You have an instant search results page with 10 products and all of them are red. It does not make sense to offer a facet with color: red (10), right? How can it be achieved to NOT see this facet?

We are using Algolia with Magento 2.


Hi Jörg,

This is not something we offer out of the box, but you can create using transformItems. You basically filter the items, and hide them if the number of hits is the same as the count for that facet:

    container: '#brand-list',
    attribute: 'brand',
    transformItems(items) {
      return items.filter((item) => {
        return item.count !== search.helper.lastResults.nbHits;

In this index, an example query where all the hits are related to a same brand is “Targus”.

Custom behaviour is like this: loving-sammet-y0nsi - CodeSandbox

Default behaviour is like this: zealous-montalcini-ekpn9 - CodeSandbox

Thanks @haroen for the fast response. This is exactly what I was looking for.

Best, Jörg

1 Like