Remove some Tags in Facets sidebar

Hi there,
I’m trying doing some JS Helper to remove some tags in Facets sidebar but all my trials are error and failed.
tags-remove

Like example I want to remove Comedy tags.
Thanks

Hi @sandrojordanmonte70 , there’s unfortunately no easy way to remove filters at query time.
One of the main reasons for this is that if you display 10 tags, we ask to Algolia the 10 most popular tags.
If you then manually remove 8 of them, the list suddenly is way less useful.

The recommended approach is instead to filter them at indexing time.
We don’t provide a way to blacklist them. However, we do provide a whitelisting solution.

I’ll take a simple example where you’d like to show Comedy, but hide Drama.
A way to do so would be to enable named tags, and to whitelist the tags you want to see with, for instance, Comedy,searchable:Drama.
Then in the Search Options tab of our app, you’d then be able to use named_tags.searchable instead of tags and have the search only use the tags you manually whitelisted.

Thanks for the reply,
Previously I did some manual customization by categorizing some of our Tags which results duplication of Tags. See screenshot below

remove-tags

The tags under # OF PLAYERS, PLAY TIME, GENRE is the one we want to remove under Tags block because it’s duplicated.

I would definitely encourage you to use actual attributes in Algolia do do so.
You could have players_amount:4,play_time:30-60 minutes,tags:Comedy.
That being said, I understand how this could not be convenient since you would have to convert all your existing tags.

An alternative would be to use transformData.item.
You would need to set it only for the tags facet.
To see an example of this function being used on another widget, you can see this parameter being used for the hits widget in algolia_instant_search.js.liquid.

To start simple, use a transformData in which you’ll output the JSON of each facet:

transformData: {
  item: function (facet) {
    console.log(facet);
    // Feel free to add content here
    return facet;
  }
}

You could then, depending on the facet value, add an attribute called hidden.
Then, in the facet template algolia_instant_search_facet_item.hogan.liquid, add a class for items that should be hidden, and add some CSS that will actually hide those.