OrientDB 从遍历中排除某些顶点

OrientDB exclude certain vertices from traverse

我希望能够从 OrientDB 遍历查询中排除某些顶点。

例如,

traverse * from (select from Location where ID = '1234')

将遍历起点的所有顶点类。我需要一种方法来为特定 类.

添加排除项

我知道如果我不使用 * 运算符而是指定我想要的所有 类 ,这是可能的。但是,它不合适,因为会有 类 我的程序甚至都不知道。数据不断变化,但要排除的 类 将始终存在。

您可以使用 difference() 函数来完成:

select expand($c)
let $a=traverse * from (select from Location where ID = '1234')
$b=select from <class to exclude>
$c=difference($a,$b)

不确定语法,但它应该可以工作

再见,伊万

不知道我理解的对不对

我有这个结构。

我想从节点A1开始遍历,不包括class B的节点和相关分支。

我使用这个查询

traverse * from #12:0 while @class<>"B"

希望对您有所帮助。

更新

我使用这个查询

select * from (traverse * from #12:0 while @class<>"B") where @class<>"E" or (@class="E" and in.@class<>"B")

更新 2

select * from (traverse * from #12:0 while @class<>"B") where @this instanceof 'V' or (@this instanceof 'E' and in.@class<>"B")