簡體   English   中英

Gremlin查詢以獲取兩個頂點之間的邊

[英]Gremlin query to get the edge between two vertices

嘗試這樣的事情

List<Edge> result = g.traversal().V().hasLabel("contextlabel").where(__.otherV().hasLabel(labelName)).bothE().toList();

但是低於錯誤org.apache.tinkerpop.gremlin.orientdb.OrientVertex無法轉換為org.apache.tinkerpop.gremlin.structure.Edge

因為V()返回了一個Vertex ,然后嘗試使用where()進行過濾,所以使用了該錯誤,它將那個Vertex作為要評估的流中的傳入項。 它試圖調用otherV() ,這不是Vertex可用的方法...該方法用於邊緣。 我認為您只是在錯誤的位置放置了bothE() ,因此

g.V().hasLabel("contextlabel").
  bothE().
  where(__.otherV().hasLabel(labelName)).

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM