Do custom rankings support case insensitive matches?

Hello,
We are creating custom rankings for our replicas and noticed our data is not getting sorted correctly because the key we are scoring can have different casing.

The example we noticed this was when we are creating rules to score on vehicle makes.

"rules" => [[
      "key" => "make",
       "value" => "Jeep"
  ]],
  "score" => 2

This will sort vehicles in our replica with “Jeep” correctly, but we also have vehicles with “JEEP” which do not get sorted as expected. Is there a way to configure the value being matched to be case insensitive?

Hi @sysops, welcome to the forum!

Generally we recommend that attributes set for custom ranking are boolean or numeric. It seems here as though you are setting it to a string attribute such as “make”, is that correct? If so, in order to have any kind of alphabetic sort on an index, this documentation should be helpful: https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-an-index-alphabetically/

That said, since you mention scores, it seems as though you might actually be using filter scoring.

If so, these are indeed case sensitive. To give the same score to differently cased versions it would necessary to either:

  1. Normalize the values at indexing time to one version. OR
  2. Add multiple filter scores, e.g.:

filters: "(make:JEEP<score=2> OR make:Jeep<score=2>)"

I hope this helps. Don’t hesitate to clarify if I didn’t understand what you are trying to do!

That does help, thank you for providing the information!