OrientDB查询所有边缘

时间:2017-06-23 11:20:19

标签: orientdb

我想在OrientDB中进行查询,但我不知道它是如何工作的。

我正在使用Graph API,我的数据库看起来像这样:

class(V):@route(姓名,开始,长度,目标)
class(V):@ direction(目标,长度)

class(E):@has_A class(E):@start_Direction class(E):@has_Follower

边缘连接到顶点,如下所示:
路线 - > has_A - >方向
路线 - > start_Direction - >方向
方向 - > has_Follower - >方向

现在我需要找到路线名称的所有粉丝, 到目前为止,当我输入一个rid(类startDirection)直接到查询时,例如:

select * from (traverse outE('has_Follower'),has_Follower.in from #??:?) where @class='direction' 

但现在我需要摆脱路线的名称(这是问题),到目前为止我尝试的是:

select * from (traverse outE('has_Follower'),has_Follower.in from (select @rid from start_Direction where start_Direction.out = (select @rid from route where Name = 'nameOfroute'))) where @class='direction' 

但这给了我一个空的查询,虽然当我输入从start_Direction中删除时,我知道有一个has_Follower它可以工作。

希望这是可以理解的,感谢您提前提供任何帮助。

1 个答案:

答案 0 :(得分:0)

您的查询中的一个问题可能是start_Direction.out = (select...,您必须使用IN而不是=,例如start_Direction.out IN (select...

总的来说,我认为最简单的方法就是如下:

 MATCH
   {class:route, as:route} -start_Direction-> {} -has_Follower-> {as:direction, while:(true)}
 RETURN route.@rid, route.Name, route.Start, route.Length, route.Goal, direction.Goal, direction.length

如果您想要每行单个记录,则只需RETURN $elements

相关问题