Gremlin 访问和比较遍历中存储的边的属性
我有以下图形模型: 我想选择通过控制器执行操作的用户。由边缘执行的包含已使用的用户密钥属性,我要使用该属性来选择由连接到所需用户的边缘调用的,条件如下:called by.user\u key==performed by.used\u user\u key属性 我将由执行的存储在操作_edge中,并尝试在步骤中使用存储的值 问题:有('user\u key',选择('action\u edge')。值('used\u user\u key'))产生随机边 问题:如何在has步骤中从存储的边缘获取/reference属性 图B:JanusGraph 0.5.2 小精灵:3.5.0 用于再现问题的Python代码段:Gremlin 访问和比较遍历中存储的边的属性,gremlin,janusgraph,gremlinpython,Gremlin,Janusgraph,Gremlinpython,我有以下图形模型: 我想选择通过控制器执行操作的用户。由边缘执行的包含已使用的用户密钥属性,我要使用该属性来选择由连接到所需用户的边缘调用的,条件如下:called by.user\u key==performed by.used\u user\u key属性 我将由执行的存储在操作_edge中,并尝试在步骤中使用存储的值 问题:有('user\u key',选择('action\u edge')。值('used\u user\u key'))产生随机边 问题:如何在has步骤中从存储的边缘获
user_a = g.addV('user').property('name', 'a').next()
user_b = g.addV('user').property('name', 'b').next()
user_c = g.addV('user').property('name', 'c').next()
controller = g.addV('controller').property('name', 'controller').next()
action = g.addV('action').property('name', 'action').next()
g.V(user_a).as_('to').V(controller).as_('from') \
.addE('called-by') \
.property('user_key', 'user_a') \
.to('to') \
.next()
g.V(user_b).as_('to').V(controller).as_('from') \
.addE('called-by') \
.property('user_key', 'user_b') \
.to('to') \
.next()
g.V(user_c).as_('to').V(controller).as_('from') \
.addE('called-by') \
.property('user_key', 'user_c') \
.to('to') \
.next()
g.V(controller).as_('to').V(action).as_('from') \
.addE('performed-by') \
.property('used_user_key', 'user_a') \
.to('to') \
.next()
# Works as expected!
user_perming_the_action = g.V(action).outE('performed-by').as_('action_edge').inV() \
.outE('called-by').has('user_key', 'user_a').inV() \
.next()
assert user_a.id == user_perming_the_action.id
# Selects random user - ignores all action_edge.used_user_key value
user_perming_the_action = g.V(action).outE('performed-by').as_('action_edge').inV() \
.outE('called-by').has('user_key', select('action_edge').values('used_user_key')).inV();
# Why it yield 3 instead of 1 edge?
assert user_perming_the_action.clone().count().next() == 3
# Returns random user
assert user_a.id == user_perming_the_action.clone().next().id
提前谢谢你的帮助 经过一些研究,我找到了以下解决问题的方法:
user_perming_the_action = g.V(action).outE('performed-by').as_('action_edge').inV() \
.outE('called-by').where(eq('action_edge')).by('user_key').by('used_user_key').inV() \
.next()
assert user_a.id == user_perming_the_action.id
我正在使用两个by调制器对不同名称的属性上的边与进行比较