Search code examples
orientdb

OrientDB exclude certain vertices from traverse


I want to be able to exclude certain vertices from an OrientDB traverse query.

For example,

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

will traverse all vertex classes at a starting point. I need a way to add exclusions for specific classes.

I know this could be possible if I didn't use the * operator and instead specify all of the classes I do want. However, it would not be suitable because there will be classes my program isn't even aware of. The data is ever changing but the classes to exclude will always be present.


Solution

  • I don't know if I understand correctly.

    I have this structure.

    enter image description here

    I want to traverse starting from the node A1 excluding node of class B and the related branch.

    I use this query

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

    enter image description here

    Hope it helps.

    UPDATE

    I use this query

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

    enter image description here

    UPDATE 2

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