Does Azure cosmos DB allows case insensitive search using Gremlin query?

36 Views Asked by At

I have a gremlin query like g.V().hasLabel('test').has('name',TextP.containing('ar')). But this query is doing case sensitive search. It is not returning me the vertices that has name Ar.

Suppose if I have 2 vertices under test label and they have names like Arhan and arhan. If I execute gremlin query g.V().hasLabel('test').has('name',TextP.containing('ar')), it is returning only arhan record. But I am expecting both the records to be retrieved irrespective of their case.

2

There are 2 best solutions below

0
Kelvin Lawrence On

Your choices are going to depend on what CosmosDB supports. I believe the version of Gremlin supported is quite old.

Gremlin now has a regex predicate (added in TinkerPop 3.6.) and in the very latest version (3.7.0) has a selection of new string functions that allow lower and upper casing of strings before testing.

Lastly, some implementations allow integration with an external full text search index.

I'm not sure if CosmosDB supports any of these options. If it does not, then the best you can really do is to test for all possible variations using or logic - which can get messy but may be your only option, along the lines of:

or(
  has('name',TextP.containing('ar'),
  has('name',TextP.containing('Ar')
  )
0
Manabu Tokunaga On

This is in addition to above answer which I confirm is accurate.

In 2024 March - Gremlin Support is 3.4.13 on Cosmos.

Please refer to: Azure Cosmos DB for Gremlin graph support and compatibility

Another Suggestion

When I started with Neptune, we did not have regex either, so all strings that needs to be case agnostic, I stored the all lower-case string. In my specific case that was email and email_lc.

Other recommendations include adding indexing service on top of your Cosmos. This was also a recommendation by AWS at that time.

Another side, if you are looking for English person names encoding the name strings into Metaphone or other Phonetic code could help in addition.