简体   繁体   English

获取Scala gremlin中两个顶点之间的传出边缘属性值

[英]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:正在做以下事情:

  1. Get all vertices with the label "A"获取标签为"A"所有顶点

  2. From those vertices follow the outward going edges which have the label "test" to vertices which have the label "B"从这些顶点沿着具有标签"test"的向外边缘到具有标签“B”的顶点

  3. 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.

相关问题 在 Titan + cassandra DB 中使用 gremlin scala 更新边缘属性值 - Update edge property value using gremlin scala in titan + cassandra DB ClassCastException而在两个顶点之间获取边缘属性值时 - ClassCastException while fetching edge property value bewteen two vertices GREMLIN for Scala:如何在单个查询中放置两个顶点之间的边并连接两个顶点之间的边 - GREMLIN for Scala : How to drop edge between two vertex and connect edges between two vertex in single query 如何从顶点 scala gremlin 获取所有传出边的所有顶点 - How to get all vertices of all outgoing edges from a vertex scala gremlin Janusgraph-检查和获取两个顶点之间的边的有效方法 - Janusgraph - efficient way to check and get edge between two vertices Gremlin:选择具有共享属性的边的顶点 - Gremlin: Select Vertices that have edges that share a property Spark Scala GraphX:两个顶点之间的最短路径 - Spark Scala GraphX: Shortest path between two vertices 在scala gremlin中创建属性密钥时发生IllegalArgumentException - IllegalArgumentException while creating property key in scala gremlin Scala,查找值是否在两个整数之间 - Scala, find if value is between two integers 检查一个值是否在两列之间,火花 scala - Check if a value is between two columns, spark scala
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM