OrientDB: Find all vertices that do not have a direct neighboring vertex of a given class

Using the OrientDB query language, how to find all the vertices in cluster a that do not have an outgoing edge ending at the vertex of class b (i.e. there is no direct neighboring vertex of class b )? It doesn't matter if they have other outgoing edges.

+6
source share
1 answer

If you have class A mapped to cluster a, you can do:

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

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

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

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

I tested the latest version 1.0rc8-SNAPSHOT and it works.

+3
source

Source: https://habr.com/ru/post/905965/


All Articles