Custom instantsearch widget for refinementList

Hello,

I have an index with an attribute for faceting (call it ‘x’) which can take the following values: x in [ ‘a’, ‘b’, ‘c1’, ‘c2’ ].

When I add a refinementList widget on attribute ‘x’, i see a menu that allows me to refine on all 4 values (‘a’, ‘b’, ‘c1’, ‘c2’).

Now suppose I want to show only 3 refinement categories on the UI: ‘a’, ‘b’, ‘c’ where ‘c’ actually means ‘c1’ OR ‘c2’. What would be the best way to achieve this?

I’ve tried playing around with synonyms (eg ‘c1’ <-> ‘c2’ and then only display ‘c1’) but that did not work.

I guess the best way would be to define my own custom widget but I am struggling to build a working prototype…

Thanks!

Hi, thanks for the question. In this case the easiest would be to actually pre-compute this C1 OR C2 value in a new value, is this feasible in your usecase?

Yes I could. I suppose I could modify the index to have attribute ‘y’ = [‘a’,‘b’,‘c’].

I was wondering if there was a more elegant solution at run time ?

Thanks for your help.

Jeremie

Unfortunately any runtime solution will be less elegant than this one, it would require you to do a complete different widget since this is a use case that is not so commonly done on frontend.

I hope it still fits your expectations of how Algolia works, thanks!

Yes it does. Thank you v much