[英]OrientDB how to get a result set of vertices and its edges in one query
I have been playing around with OrientDB sql queries to get a result set that contains not only vertices but also the internal edges that exists between them. 我一直在使用OrientDB sql查询来获得一个结果集,该结果集不仅包含顶点,而且还包含它们之间存在的内部边缘。
The query could be expressed as: 该查询可以表示为:
project
(without project itself) and all the edges between the vertices that are included in the results project
相关的所有顶点(没有项目本身)以及结果中包含的所有顶点之间的边 Here is how I have achieved it but I think it is not the proper way to do it. 这是我实现它的方式,但是我认为这不是正确的方法。
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)
And the expected results: 和预期的结果:
Problems with this solution: 该解决方案存在的问题:
select from V where label = 'project'
is also executed several times. select from V where label = 'project'
也执行了几次。 Is there a better way to solve this use case? 有没有更好的方法来解决此用例?
Thanks. 谢谢。
Try this query: 试试这个查询:
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.