Reputation: 35641
In a CosmosDB Graph collection, I'm trying to find all nodes of type typeA
that do not have any "live" edges pointing to nodes of type typeB
.
Some edges may be "soft-deleted" (i.e. g.E().has('softDeleted', true)
). These edges should be ignored.
This is what I tried:
g.V().hasLabel('typeA')
-> returns 10 nodes of type "typeA", as expected
g.V().hasLabel('typeA')
.outE().not(has('softDelete', true))
.inV().hasLabel('typeB')
-> returns 2 nodes of type "typeB", as expected
g.V().hasLabel('typeA')
.where( // same condition as above, inside a 'where' clause
outE().not(has('softDelete', true))
.inV().hasLabel('typeB')
.count().is(eq(0)) // " where there are no such edges"
)
-> returns all 10 nodes of type "typeA" again ?!
In the query above, applying the where
clause seems to not filter anything.
Upvotes: 0
Views: 393
Reputation: 10904
The following query will find all typeA
vertices that do not have an edge to a typeB
vertex. Only edges that have no softDelete
property or that edges that have softDelete
set to false
will be considered, other edges will be ignored.
g.V().hasLabel('typeA').
not(outE().or(hasNot('softDelete'),
has ('softDelete', false)).
inV().hasLabel('typeB'))
Upvotes: 1