简体   繁体   中英

Gremlin - get list of vertices mapped to edge type for each vertex

I'm trying to do something similar to SQL join operation with Gremlin in Azure Cosmos.

What I'm trying to achieve is something like this. If we take the example of TinkerPop modern graph example-

在此处输入图片说明

I want to retrieve all vertices but for each vertice, also get a map with keys being the relationship type and value being an array of vertices of that relationship. For the vertex id:1 , that would be:

name: marko
age: 29
relationships: {
    created: [<node id:3>],
    knows: [<node id:2>, <node id:4>]
}

I'm unable to understand how to achieve this, or even if it can be achieved.

You can use project step:

g.V().has('name', 'marko').project('name', 'age', 'relationships')
.by(values('name'))
.by(values('age'))
.by(outE().group().by(label()).by(inV().fold()))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM