CosmosDB accent (diacritics) insensitive query

Guilherme Molin 1 Reputation point
2021-09-14T15:56:13.08+00:00

Hello, I've searched everywhere but did not found the anwser I was looking for.
How do I query CosmosDB ignoring accents?
Example:
{"id": "1", "name": "Émpresa 1" }
{"id": "2", "name": "empresa 2" }

SELECT * FROM container_name WHERE name LIKE 'empresa%'

I want to retrieve both records from this query, how can I do that?
If it's not possible "out of the box" then is there any workaround?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,904 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,631 Reputation points
    2021-09-15T07:31:22.057+00:00

    Hi @Guilherme Molin ,

    One way to do it is through the like operator by removing the diacritics character as mentioned in the below thread on Stack:

    SELECT * FROM c WHERE c.name LIKE "%mpresa%"  
    

    CosmosDB accent (diacritics) insensitive query

    Same article talks about using Azure Cognitive Search which can also be used.

    Please let us know if this helps.

    ----------

    Please don't forgot to click on accept it as answer button 132284-image.png wherever the information provided helps you. This can be beneficial to other community members as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.