Instantsearch search state case sensitivity

Hi, I have kind of an oddly specific one today, so hopefully I can explain it in a way that makes sense.

I am using SEO friendly url routing to map selected facet filter values directly to the url. So if I have a cars search and select a “make” filter of “Nissan”, the url might look like /cars/make/nissan. I can then read the url and pre-apply that filter on page refresh/load.

This works great except for one thing. The client wants the urls to be all lower case. So when I refresh the page and my logic converts the url to search state, I am setting the facet filter for “make” to “nissan” instead of “Nissan”. Which does actually work for filtering purposes, except that in my RefinementList React component, “nissan” does not show up as an option (but “Nissan” does, and it is not checked).

I know in this example I could just capitalize the value, but that doesn’t quite work for situations where capitalization is unpredictable. For example, if you had a TV shows search with a filter for “station”, you might have Fox alongside options like ABC or CNN.

So my question is, is there any way for my RefinementList component to recognize that “nissan” and “Nissan” are the same filter?

Hello @adam.tsai,
Sorry for the late reply.

I understand you’re trying to make the url lower-case. But as you said, there are unpredictable cases. If there isn’t, you can have a function which can convert both facet to url, and url to facet.

Now that you have unpredictable cases, I don’t have a good approach except for having a mapping table on your frontend for lower cases and the original cases, which seems kind of excessive, and unmaintainble in the long run.

Since the URLs are going to be the source of truth, if they’re already lower case, then I don’t see a good way except for having a perfect converter function or a excessive mapping table.

What do you think? Sorry that I’m not so helpful.