[英]Want two Vertices off the same Edge in Gremlin
I have a graph like this我有一个这样的图表
V('Producer')-E('RESPONSIBLE_PRODUCER)->V('Event')<-E('INSPECTED')-V('Engineer')
V('Event')<-E('ALIGNED_PRODUCER')-V('Producer')
That is, each 'Event' vertex has two incoming edges: one that terminates at an 'Engineer' vertex and another that terminates at a 'Producer' vertex.也就是说,每个“事件”顶点都有两条传入边:一条终止于“工程师”顶点,另一条终止于“生产者”顶点。 But the function of the Producer vertices are different depend on the edge label.
但是 Producer 顶点的功能因边标签而异。
I want to get the originating Producer, the Event, Engineer and terminating Producer.我想获得原始生产者、事件、工程师和终止生产者。
I have this gremlin code:我有这个小鬼代码:
g.V().hasLabel('Producer').
as('responsible').
has('ProdId', 1234567).
out("RESPONSIBLE_PRODUCER").hasLabel('Event').as('event').
in("INSPECTED").hasLabel('Engineer').as('engineer').
select('responsible', 'event', 'engineer').
by(valueMap('name')).by(valueMap('name')).by(valueMap('name'))
That is, I chose a given Producer and get the Event and Engineer then return some details about each of those vertices.也就是说,我选择了一个给定的 Producer 并获取 Event 和 Engineer,然后返回有关每个顶点的一些详细信息。
I also want the Producer aligned to the Event in the same query but am not sure how to do this.我还希望 Producer 与同一查询中的 Event 对齐,但不确定如何执行此操作。
Any help is greatly appreciated.任何帮助是极大的赞赏。
You are looking for project
:您正在寻找
project
:
g.V().has('Producer', 'ProdId', '1').as('r').
out("RESPONSIBLE_PRODUCER").hasLabel('Event').
project('responsible', 'event', 'engineer', 'aligned').
by(select('r').values('name')).
by(values('name')).
by(in('INSPECTED').values('name')).
by(in('ALIGNED_PRODUCER').values('name'))
You can see a "live" example of your problem here您可以在此处查看问题的“实时”示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.