benjovanic
benjovanic

Reputation: 537

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.

Upvotes: 1

Views: 296

Answers (2)

Alessandro Rota
Alessandro Rota

Reputation: 3570

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")

Upvotes: 4

Ivan Mainetti
Ivan Mainetti

Reputation: 1982

You can do it by using the difference() function:

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

not sure about the synthax, but it should work

Bye, Ivan

Upvotes: 0

Related Questions