Search Azure Cosmos DB Template

Is it possible to search for the properties of the Vertex using a contains in Azure Cosmos Graph DB?

For example, I would like to find all persons who have a name 'Jr' ?

 gV().hasLabel('person').has('name',within('Jr')).values('name') 

It seems that the within('') function only filters values โ€‹โ€‹that are exactly equal to 'Jr' . I am looking for a list. Perfectly case insensitive.

+12
gremlin azure-cosmosdb
source share
2 answers

There are currently no text matching features available for CosmosDB. However, I was able to implement a wildcard search function using UDF (User Defined Function), which uses the Javascript match () function:

 function userDefinedFunction(input, pattern) { return input.match(pattern) !== null; }; 

Then you will need to write your query as SQL and use the UDF that you defined (in the example below, it is assumed that you called the REGEX function

 SELECT * FROM c where(udf.REGEX(c.name[0]._value, '.*Jr.*') and c.label='person') 

Performance will be far from ideal, so you need to decide whether the solution is acceptable or not, based on your latent and cost prospects.

+3
source share

The Azure team has implemented Tinkerpop predicates for String.

The Azure team "announced" this to the user here on their feedback website.

I have not checked all of them, but contains works for me (although case sensitive)

 gV().hasLabel('doc').or(__.has('title', containing('truc')), __.has('tags', containing('truc'))) 

TextP.startingWith (string)

Does the incoming line begin with the provided string?

TextP.endingWith (string)

Does the incoming string end with a provided string?

TextP.containing (string)

Does the input string contain the provided string?

TextP.notStartingWith (string)

Does the incoming line not start with the specified line?

TextP.notEndingWith (string)

Doesn't the incoming string end with the provided string?

TextP.notContaining (string)

Does the incoming string not contain the provided string?

0
source share

All Articles