繁体   English   中英

OrientDB如何在一个查询中获得顶点及其边的结果集

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM