0

I have 2 problem statements with similar approach .Can I put a contains or like query in both to solve my problem in gremlin:

1) Returning vertex 'a' in the following query when the outE() (as depicted in below gremlin query) has label with contains print.

g.V().hasLabel('url').has('name','sw10707').as('a').outE('print').has('forward','states').inV().select('a')

2) Returning all the vertices as stated below which contains print in their edge labels:

g.V().hasLabel('url').has('name','sw10707').as('a').outE('print').has('forward','states').inV()

This query is not working: g.V().hasLabel('url').has('name','sw10707').as('a').outE().filter(it.name.matches('.pri.'))

An issue is already open with .net driver ( but I am not able to find similar functionality with java) : https://github.com/Azure/azure-cosmosdb-dotnet/issues/473

Varun Tahin
  • 299
  • 1
  • 2
  • 15

1 Answers1

1

This traversal:

g.V().hasLabel('url').
  has('name','sw10707').as('a').
  outE().filter(it.name.matches('.pri.'))

requires a lambda expression in filter() and should be written as a Groovy closure:

g.V().hasLabel('url').
  has('name','sw10707').
  outE().filter{it.name.matches('.pri.')}

Unfortunately, CosmosDB does not support lambdas so your traversal will fail. At this time, there isn't a workaround that I know of short of returning the edges to filter them on the client and then using them to start a second traversal...not great. Hopefully the issue you raised will bring some relief soon.

Note that I commented on that issue to mention that TinkerPop is considering making those text predicates available - the discussion is here.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Ok Thanks. Is it possible that we can query using SQL contains expression in azure db (if the database location is same for both cosmos graph and sql db in azure ) and get some data out of it for further query on graph? Sorry if this question is vague as I am new to Azure Cosmos. – Varun Tahin Sep 18 '18 at 04:59
  • FYI , I tried using cypher client for gremlin server also ( https://github.com/opencypher/cypher-for-gremlin/blob/master/tinkerpop/cypher-gremlin-server-client/README.md ) . This bug persists as I tried running several queries with contains and regex . Both are not working . Do you have a workaround on that or that will be general for azure Cosmos. Queries that I tried: MATCH (u:url{name:'sw8230'})-[r]->(o:otherentities) where type(r)=~'.*exporting.*' RETURN o AND MATCH (u:url{name:'sw8230'})-[r]->(o:otherentities) where type(r) contains 'exporting' RETURN o . Please recommend . – Varun Tahin Sep 18 '18 at 09:18
  • This is an issue with CosmosDB. It has nothing to do with the query language. I think you probably need to try out your idea with `contains` - sounds like a possible workaround, but I don't know for sure. – stephen mallette Sep 18 '18 at 10:34