简体   繁体   English

想要 Gremlin 中同一边的两个顶点

[英]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.

相关问题 Gremlin查询以获取两个顶点之间的边 - Gremlin query to get the edge between two vertices 如何在 CosmosDB 中使用 Gremlin 找到两个顶点之间的边 - How can I find an Edge between two Vertices with Gremlin in CosmosDB 如何使用gremlin在两个顶点之间创建双向边? - How to create a bidirectional edge between two vertices using gremlin? Gremlin,得到两个彼此有边的顶点 - Gremlin, get two vertices that both have an edge to each other 在 Gremlin 中以原子方式添加两个顶点和一条边的最佳方法 - Best way to add two vertices and an edge atomically in Gremlin 获取Scala gremlin中两个顶点之间的传出边缘属性值 - Fetch outgoing edge property value between two vertices in scala gremlin Gremlin:在两个顶点之间找到边缘的有效方法是什么? - Gremlin: What's an efficient way of finding an edge between two vertices? 如何在Gremlin中找到两个顶点之间的Edge ID - How to find the Edge ID between two vertices in Gremlin 在gremlin中遵循相同类型的顶点(共享相同标签的顶点)之间的特定关系(带有特定标签的边) - Follow a certain relationship (edge with a certain label) between the same kind of vertices (vertices that share the same label) in gremlin 在 Gremlin 中,如何在一个属性上查询两个或多个具有相同值的顶点? - In Gremlin, how to query two or more vertices with same value on one property?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM