OrientDB Traverse until class X

68 views Asked by At

How can I traverse a graph from a node until a node of type X and no further? The assumption is that eventually all paths lead to X.

I tried this query but it still give me paths which continue past entities of type X

traverse * from #32:3 WHILE not($current instanceof 'X')

Any advice?

1

There are 1 answers

3
Lvca On

Please try this:

traverse * from #32:3 WHILE $current.@class <> 'X'

This is not polymorphic, so it works only for instances of type X, not its subclasses.

Note that using * wildcard means traversing all edges of any type. Is this what you want? It's always better to specify the direction and/or the edge label(s) to have better performance.