[英]Fetch outgoing edge property value between two vertices in scala gremlin
I am trying to fetch edge property value between two vertices.我正在尝试获取两个顶点之间的边属性值。 Eg A-->BA and B are two vertices and it has edge with property(name).例如,A-->BA 和 B 是两个顶点,它具有属性(名称)的边。
My code looks like:我的代码看起来像:
graph.V().hasLabel(A).outE().value("name").headOption()
It gives me the property value for name.它为我提供了名称的属性值。
In a given two vertices, i am getting None as output在给定的两个顶点中,我得到 None 作为输出
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
' test ' - Edge Label ' name ' - Edge property “测试”-边缘标签“名称”-边缘属性
Any idea what is wrong with my query.知道我的查询有什么问题。
Apologies for not being able to answer this in your comments on the previous question you asked.很抱歉无法在您对之前提出的问题的评论中回答这个问题。 I think what you are looking for is:我认为你正在寻找的是:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").properties("name");
If you just want the values of the properties on the edge you can do the following:如果您只想要边缘上的属性值,您可以执行以下操作:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").values("name");
Side Note (Why is your original traversal wrong): Your original traversal:旁注(为什么你原来的遍历是错误的):你原来的遍历:
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
is doing the following:正在做以下事情:
Get all vertices with the label "A"
获取标签为"A"
所有顶点
From those vertices follow the outward going edges which have the label "test"
to vertices which have the label "B"从这些顶点沿着具有标签"test"
的向外边缘到具有标签“B”的顶点
Then get the property "name"
from those vertices然后从这些顶点获取属性"name"
You are actually asking for the properties on the vertex.您实际上是在要求顶点上的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.