Facets with slug alias

Hi all,

I’m working on an e-commerce site, and building a brands filter using the refinement connector. Each brand has a name and a slug, with the brand being what the user sees, and the slug being what gets passed onto the API amongst other internal hidden functionality.

Index structure is as follows:

productId:	123xyz
productName:	Rustic Copper Shoes
productSlug:	rustic-copper-shoes
brand: {
   name: Quitzon, Klein and Hegmann, 
   slug: quitzon-klein-and-hegmann

The marketplace is currently working perfectly fine with using brand.name for the attribute field, however, I want to add a callback from the checkbox to handle the slug, not name. The slug doesn’t appear anywhere in Algolia’s query response, and it looks like I can’t simply use brand as the attribute, with the hopes of getting both name and slug to play with.

Does anyone have any guidance?

Hi @shneor,

I’m not sure I have completely understood what you’re trying to do. Let me recap to be sure we are on the same page: you’ve built a custom RefinementList widget on the attribute brand.name but you also want to have access to the slug once you click on the checkbox. Is it correct? It’s expected to not have access to it from the connector since the attribute declared as facet is only brand.name you only get this value. You can’t declare brand as facet because it’s an object the value has to be literal.

Could you give us a bit more context of what you’re trying to do? It will help to better understand the use case and provide a potential solution. You can even create an example, we provide template to avoid you the boilerplate part. You can find the list of templates on this page (“Previews” section), pick the flavour you want.


It sounds like we’re on the same page, but it’s not so late in the day so I can think and articulate more clearly this time :slight_smile:

I have a checkbox list which is wrapped in a connectRefinementList which by itself is working as expected, with human-readable brand names which can be checked, filtering products accordingly.

However, on an onCheck action, there are some side-effects that need to happen, eg some api calls, updating browser address bar, other UI updates etc. Some of these side effects require the slug of the selected items, however there’s no way that I can find for Algolia to return that extra piece of meta information; perhaps in the same way it returns count and isRefined would be ideal.

In light of this, there are some other workarounds that have come to mind of this morning, eg

  1. getting a look-up table from our internal API - not exactly optimal and we don’t want to overshare data to the user.
  2. stringifying the brand object in the Algolia index and parsing that in the FE to split into a label and slug - feel like this would work but also feels a bit hacky in general
  3. some kind of advanced query that I need to still figure out.

Hi @shneor,

Thanks for those explanations, indeed there is no built-in solution to find “meta” information tied to a facet. It’s a known issue that I was not aware of. The second solution you’ve suggested should work and it’s the one we already advocated for in the past.

I’ve sent a feedback to our product team about this use case since it’s not the first time we meet this limitation. Anyway if you have any questions on how to implement the solution don’t hesitate to reach out.


Thanks for that info. I’ll hope that one day in the future this kind of meta info is supported and in the mean time make do with this less-ideal json-stringified solution.

Hi @samuel.vaillant,

We have the same issue. Do you have a solution ?

We have the same issue. Any fixes yet?