1

I have Cosmos db as our database and my java application runs on Spring Boot. I'm using Spring Data's MongoRepository to query the database.

I have a requirement where I need to find results based on a field and it needs to be case insensitive.

What I tried ...

  1. appending mongorepository method with "IgnoreCase"
  2. adding regex in query ... @Query("{fieldName: {$regex: '^?0$', $options: 'i'}}")

The above solutions work with my mongodb(on my local) but doesn't work on cosmosdb .

I thought that the issue might be because of version of the software I'm using or some driver I'm using so I ran the same query on mongocompass (connecting to mongodb) and robo3t (connecting to cosmosdb), but the query doesn't with cosmos.

So my assumption is cosmos doesn't support the above queries

Now i'm not going to switch to mongodb since i'm not the one making the decision, i'm stuck with cosmos and I have to provide solution to the latter.

I've searched about collation, but haven't found any results or documentation on how to do it with cosmosdb and most likely this is not an option for me.

So is there any other way to query the database with no case sensitivity or is there anything wrong which I'm doing here?

Stennie
  • 63,885
  • 14
  • 149
  • 175
  • Look here: https://stackoverflow.com/questions/30512806/how-to-do-a-case-insensitive-search-on-azure-documentdb – Olha Shumeliuk Jul 11 '18 at 05:41
  • @OlgaShumeliuk the link you provided shows sql queries, this will not work on nosql version of cosmos db. – Abhishek Kakkerla Jul 11 '18 at 17:55
  • Possible duplicate of [How to do a Case Insensitive search on Azure DocumentDb?](https://stackoverflow.com/questions/30512806/how-to-do-a-case-insensitive-search-on-azure-documentdb) – Imre Pühvel Jul 12 '18 at 10:14
  • CosmosDB can be queried using various syntaxes, SQL is one of them. The link by OlgaShumeliuk is spot on. – Imre Pühvel Jul 12 '18 at 10:16

0 Answers0