在 Gremlin 查询语言中获取边属性以及源和目标顶点 ID

Get edge properties as well as source and target vertex ID in Gremlin query language

我正在尝试检索边缘属性作为值以及目标和源节点 ID。

我当前的数据库是这样的:

边缘:

_id _label _outV _inV name ID
0   edge   0     1    E    0

节点:

_id _label _name ID
0   node   A     0
1   node   B     1

我试过这个查询:

>g.V().as('a').outE('edge').as('b').inV().values('ID').as('to').
 select('b').valueMap().as('edge').
 select('a').values('ID').as('from').
 select('to','edge','from')
==>[to:0,edge:[ID:0,name:E],from:1]

我想得到的是

[to:0,ID:0,name:E,from:1]

边缘元素也可以包含任意数量的属性。

有办法实现吗?

谢谢!

编辑: 最终查询:

gremlin> g.V().outE('edge').limit(1).
......1>   project('weight','id','from','to').
......2>     by(coalesce(values('weight'),constant(''))).
......3>     by(id).
......4>     by(outV().id()).
......5>     by(inV().id())
==>[weight:,id:0,from:0,to:1]

使用project():

gremlin> g.V().has('name','marko').
......1>   outE().limit(1).
......2>   project('weight','id','from','to').
......3>     by('weight').
......4>     by(id).
......5>     by(outV().id()).
......6>     by(inV().id())
==>[weight:0.4,id:9,from:1,to:3]