Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrientDB: Find all vertices that have no direct neighbour vertex of a given class

Using OrientDB's query language, how can find all vertices in cluster a that have no outgoing edge ending in a vertex of class b (i.e. no direct neighbour vertex of class b)? It does not matter if they have other outgoing edges.

like image 273
Thilo Avatar asked Jan 14 '12 12:01

Thilo


1 Answers

If you've a class A mapped to cluster a you can do:

select from A where not( out.in.@class in ['b'] )

That means cross the "out" property of A records (as edges), then the "in" property (the vertex) and then get the class name (@class). I've used the IN operator instead of = (equals) because "out.in.@class" returns a collection of class names.

If you want have no A class and you have to go through the cluster A use cluster: syntax:

 select from cluster:A where not( out.in.@class in ['b'] )

I've tested against latest 1.0rc8-SNAPSHOT and works.

like image 114
Lvca Avatar answered Dec 08 '22 01:12

Lvca