Possible to set the value & label for facet value?

Any chance that’s possible? In the index I’ve tried setting up the facet value like so…

"country": "newSouthWales,Australia||New South Wales, Australia",

…and I have it working with the following in the front-end…


…though that seems kind of clunky? Is there a better way? I’m using the MenuSelect with ReactInstantSearch.

Thanks so much!

Hi @markaugias, Could you explain your problem again? I am unable to understand your problem. Maybe a screenshot or loom would help!

Hi mate, thanks for getting back to me.
So I have a facet defined like this…

On the front end the logged data for each item in my SelectMenu looks like this…

I was hoping there’s an easy way to define the value (congoAndDemocraticRepublicOfCongo) and the label (Congo and Democratic Republic of Congo) within the facet value?

If I set the facet value to be congoAndDemocraticRepublicOfCongo||Congo and Democratic Republic of Congo I can then split it on the front end by doing…


…but that seems clunky. Wondering if there’s a better way??


Hey Marc,

I wondered that same thing a while back but I just got used to it… single vertical bar for me.
Naming convention with <id>|<title> and no problems… I’ve got lots of these.


1 Like

That’s great to know, thanks for helping me put my mind at rest… cheers

Hey @markaugias Sorry for the delay in response. I am sorry, I still do not understand the problem.

Let me know if my explanation is correct.

  1. You have records like this
    [{“country”: “congoAndDemocraticRepublicOfCongo”}, {“country”: “anotherCountry”}, …]

  2. You configured the Attributes for faceting as “country”

  3. Now in your instantsearch widget you receive “congoAndDemocraticRepublicOfCongo” and “anotherCountry” as values which users can filter on.

  4. You want to use a different label to display “congoAndDemocraticRepublicOfCongo” as “Congo and Democratic Republic of Congo”

Is my explanation correct?

Yep that’s about right for an explanation of what I’m trying to achieve.
My only solution so far was using a separator (||) to divide value and label… so something like this:

{“country”: “congoAndDemocraticRepublicOfCongo||Congo and Democratic Republic of Congo”}, {“country”: “anotherCountry||Another Country ”}, …]

Then on the frontend use that separator to split into value & label… which can work, but, seems a little clunky to my mind.

Thanks for getting back to me.


@markaugias May I ask why do you have country stored like that in the first place? It could be due to specific use case for your application, but I’d still like to know.

If you have the capability to modify your country like that, why don’t you create a new attribute when you index it.

[{country: “congoAndDemocraticRepublicOfCongo”, countryLabel: “Congo and Democratic Republic of Congo”}, …]

Then use countryLabel in your facets.