1

I'm trying to find an Edge between two Vertices that I know the IDs of.

I found this thread Gremlin: What's an efficient way of finding an edge between two vertices? . But that doesn't seem to work with the Cosmos implementation.

I tried g.V('1').outE('isInvited').filter(inV().is('2')) but that just gives me this error. Gremlin Query Compilation Error: Unable to find any method 'filter'

Then I tried g.V('1').outE('isInvited').has('inV', '2') but that just consistently gives me an empty result even when I know that there is such an Edge.

Is there a way to do this with the CosmosDB gremlin implementation?

The Hoff
  • 904
  • 1
  • 11
  • 22

2 Answers2

3

I produced your issue on my side actually. With the filter command in the thread you provided, the output is :

enter image description here

Then I get clues from the Gremlin API supported features, you could use Where instead of Filter.

enter image description here

Command:

g.V('7c5dbd78-2840-402c-88ca-96e8eab4a33b').outE('knows').where(inV().is('e2d68f31-2ea1-486e-a17f-d3c596ef9245'))

Output:

enter image description here

Jay Gong
  • 23,163
  • 2
  • 27
  • 32
0

g.V().has('your_node_label','id','your_from_node_id').outE('edge_label_1','edge_label_2').inV().has('your_node_label','id','your_to_node_id')

You can specify more than one edge label in the outE() method.

And the query returns the 'to' node.

Please make sure that you are using the label name with the queries. Otherwise, the graph traverses all the nodes and query performance will decrease

Hrishikesh T T
  • 339
  • 2
  • 11