[英]OrientDB how to get a set of vertices and edges that satisfy a given traverse path?
[英]OrientDB how to get a result set of vertices and its edges in one query
我一直在使用OrientDB sql查詢來獲得一個結果集,該結果集不僅包含頂點,而且還包含它們之間存在的內部邊緣。
該查詢可以表示為:
project
相關的所有頂點(沒有項目本身)以及結果中包含的所有頂點之間的邊 這是我實現它的方式,但是我認為這不是正確的方法。
select expand($union) let $vertices = ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ), $edges = ( select from ( select from E where @rid in ( select bothE() from ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) ) ) where out in ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) and in in ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) ), $union = unionall($vertices, $edges)
和預期的結果:
該解決方案存在的問題:
select from V where label = 'project'
也執行了幾次。 有沒有更好的方法來解決此用例?
謝謝。
試試這個查詢:
select expand($c)
let $a=(traverse both(),bothE() from (select from V where label="project")),
$b=(traverse bothE() from (select from V where label="project")),
$c=difference($a,$b)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.