简体   繁体   中英

How to get the properties of two or more vertices in one Gremlin query?

How to get the properties (ids) of two vertices in one Gremlin query?

g.addV('user').property(T.id, 'US001').property('name', 'Thirumal')
g.addV('role').property(T.id, 'EMP001').property('role_name', 'Developer')
g.V('US001').addE('employee').to(g.V('EMP001')).property('from', '2021/04/01')

How to get the following fields in one query like SQL joins?

 1. id of the user node
 2. name 
 3. id of employee node
 4. role_name 
 5. from - Employee edge

I suppose that if you wanted it all flattened in a "row" like the result of a SQL query you might do:

gremlin> g.V('US001').as('uid','name').outE().as('from').inV().as('eid','role').
......1>   select('uid','name','from','eid','role').
......2>     by(id).
......3>     by('name').
......4>     by('from').
......5>     by(id).
......6>     by('role_name')
==>[uid:US001,name:Thirumal,from:2021/04/01,eid:EMP001,role:Developer]

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