![](/img/trans.png)
[英]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.