0

I am currently evaluating Neo4j against Cosmos db graph . As the present system lies in cosmos thus we started building graph in cosmos . But in recent times came to know about certain tinkerpop3 queries which are not supported in cosmos db graph like regex, filter and other lambda operations.

Do we have a list of such supported/unsupported operations anywhere so that we are in better place to choose between the two databases without compromising on the features we wish to build.

Varun Tahin
  • 299
  • 1
  • 2
  • 15

1 Answers1

1

The full list of Gremlin steps supported by CosmosDB can be found here. It is worth clarifying that TinkerPop does not support regex natively. You can only do that through a lambda expression with filter() step:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> p = Pattern.compile("(marko|j.*h)")
==>(marko|j.*h)
gremlin> g.V().values('name').filter{p.matcher(it.get()).matches()}
==>marko
==>josh

While this works, there is no graph that I am aware of that will optimize that particular traversal (i.e. it will not be index based). In fact, no graph will optimize any lambda - it is arbitrary code that the graph will simply execute. You will need to look for graphs that natively support regex or some form of full-text search. The only ones that I know of that have such support in Gremlin itself would be JanusGraph and DSE Graph. Other graphs do have such support natively, but it isn't necessarily exposed in a way that it could be used in Gremlin directly.

TinkerPop is adding native support for text predicates now that more graphs seem to be supporting this feature and the pattern for doing so is relative consistent. We should see that in TinkerPop 3.4.0 when that is released.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks for the clarification . But still cosmos db does not support lambda expressions. Can we do it via firing SQL like queries and getting answers in Cosmos and then start traversal with the retrieved vertices? – Varun Tahin Sep 27 '18 at 05:13
  • I don't know the answer to that, but it sounds like a reasonable thing for you to try. – stephen mallette Sep 27 '18 at 10:17