Query a number, don't allow typo's but replace the country code

Dear Algolia Community,

We have an indice “companies_index” which contains an attribute “phone”. With our application we are trying to match a given phone-number to an object in the indice. It’s important that typo’s are not allowed for phone numbers, therefor we disabled typos for numbers. This works perfect.

However sometimes the search query we hit Algolia with will contain the country code.

Example:

  • In the indice: “phone” => “0251860261”
  • In the query “+31251860261”

We are looking for a way that allows us to replace “+31” with “0” when a search query contains or starts with +31.

If this is not possible but you have a better suggestion We’d love to hear it!

Hopefully you guys can help us out :), any tips appreciated.

Best Regards,

Nils

Hello Nils,

The best option is to replace the country code with 0 before sending the query to Algolia. The other option would be to duplicate the fields in your records to contain the phone number with and without the country code, which is more cumbersome and would increase your record size. I’d suggest to stay with the first option.

Hi Anthony,

Thanks for your reply!

Ah, I did not know that it was better to do this application-side. Now I know :slight_smile: .

Should not be a problem to fix this then. Thanks again and have a nice day!