Use object as facet filter

Hi,
I have some data in algolia index looks like:

 {
  name: 'Samsung',
  productGroup: {
    id: 1, 
    description: 'this is the description'
}

can I use productGroup as facet, then in the page it displaysproductGroup.description, but use productGroup.id to do the filter?

Thanks.

Hi @qingshan.zhuan, unfortunately this is not possible for now. I have forwarded it to our feedback board however. In the mean time, what you can do is change your facet to:

{
  productGroup: "1--this is the description",
}

Then in the UI you transform the filter to the id and the description by doing productGroup.split('--').

In InstantSearch you can do that in transformItems specifically for the label.

Hope the workaround makes sense for you!

1 Like

Thanks @haroen. I will go this solution for now :slight_smile:

1 Like