Cypher - odd behavior when matching nodes that have no relationship

I am trying to filter out all nodes that are not connected to nodes of this type and have detected odd behavior.

In particular, in my current small example, I had two actors connected to one film, and another film in which nothing was connected with it.

This request worked fine:

MATCH (a:Actor) WHERE NOT (a)-->(:Movie) RETURN a

He did not return the actors, since both actors starred in the same film.

However, when I wrote this as

MATCH (a:Actor),(m:Movie) WHERE NOT (a)-->(m) RETURN a

he returned both members.

In reverse order

MATCH (m:Movie) WHERE NOT (m)<--(:Actor) RETURN m

worked as expected, returning a film in which no one played, but this time

MATCH (m:Movie),(a:Actor) WHERE NOT (m)<--(a) RETURN m

also only a movie that no one has played back is back! However, it was strange that he returned 2 lines, both of which were films in which no one had played.

In general, I am completely confused.

+4
1

, , . , , , , .

MATCH (a:Actor),(m:Movie) WHERE NOT (a)-->(m) RETURN a

?

4 , , , , .

MATCH (a:Actor),(m:Movie) RETURN m,a

where

MATCH (a:Actor),(m:Movie) WHERE NOT (a)-->(m) RETURN m,a
+2

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


All Articles