Ok, first create an example graph:
gremlin> v1 = graph.addVertex('name', 'v1') ==>v[0] gremlin> v2 = graph.addVertex('name', 'v2') ==>v[2] gremlin> v3 = graph.addVertex('name', 'v3') ==>v[4] gremlin> v4 = graph.addVertex('name', 'v4') ==>v[6] gremlin> v1.addEdge('knows', v2, 'property1', 10) ==>e[8][0-knows->2] gremlin> v1.addEdge('knows', v2, 'property1', 20) ==>e[9][0-knows->2] gremlin> v2.addEdge('knows', v3, 'property1', 10) ==>e[10][2-knows->4] gremlin> v2.addEdge('knows', v4, 'property1', 50) ==>e[11][2-knows->6]
Now we have a simple graph, where two edges go from v1 to v2 with the values ββof properties 10 and 20. v2 has two outgoing edges, of which one edge has the value of property 10. This is the edge to which the query should go, and the resulting vertex is v3.
One way to do this with match()
-step :
gV(v1).outE().match( __.as('e1').values('property1').as('p1'), __.as('e1').inV().as('v2'), __.as('v2').outE().as('e2'), __.as('e2').values('property1').as('p2'). where('p1', eq('p2'))). select('e2').inV().values('name') ==>v3
Full example in GremlinBin: http://gremlinbin.com/bin/view/5809c1fc0626b
source share