Categories tree with products belonging to multiple categories


We are integrating Algolia search in company but have faced the problem with categories faceting. The problem is we have products which can belong to multiple categories. But those categories have parent categories, so there is a categories tree with products that can be basically anywhere.

Should we implement this by variants of product ( so every product gets duplicated for every root category? Or are we able to implement this using some mechanism that already exists in Algolia?

Thanks in advance

It depends how you want to facet for it, but usually what you do is the following:

  1. you add an array of the applying categories to each item
  2. you add a disjunctive filter on the frontend

Disjunctive is a bit of a complicated word, but what that means is using the Menu or RefinementList widgets of InstantSearch. There’s versions of InstantSearch for multiple frameworks available, as well as for vanilla JS.

It’s also possible to use the JS Helper to do this disjunctive faceting.

Hope that helps!

1 Like