【问题标题】:OrientDB exclude certain vertices from traverseOrientDB 从遍历中排除某些顶点
【发布时间】:2016-05-17 11:37:57
【问题描述】:

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

例如,

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

将在起点遍历所有顶点类。我需要一种为特定类添加排除项的方法。

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

【问题讨论】:

    标签: orientdb


    【解决方案1】:

    不知道我理解的对不对。

    我有这个结构。

    我想从节点A1开始遍历,不包括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")
    

    【讨论】:

    • 这太棒了!但是,它仍然返回悬垂边缘。我们也可以排除这些吗?
    【解决方案2】:

    您可以使用difference() 函数来做到这一点:

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

    不确定合成器,但它应该可以工作

    再见,伊万

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多