cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Graph Academy 2MATCH patterns

In graphacademy/online-training/ Part 5 . we retrieve the actors who acted in the same movies as Keanu Reeves , but not when Hugo Weaving acted in the same movie.

MATCH (keanu:Person)-[:ACTED_IN]->(movie:Movie)<-[:ACTED_IN]-(n:Person),
(hugo:Person)
WHERE keanu.name='Keanu Reeves' AND
hugo.name='Hugo Weaving'
AND NOT (hugo)-[:ACTED_IN]->(movie)
RETURN n.name

This query witch return 10 ACTORS. I thought my query was equivalent :

MATCH (keanu:Person)-[:ACTED_IN]->(movie:Movie)<-[:ACTED_IN]-(n:Person)
WHERE keanu.name='Keanu Reeves' AND
NOT n.name='Hugo Weaving'
RETURN DISTINCT n.name

But it returns 13 row. And I don' t see the difference in the query . Can someone explain what i'm missing? THX

1 ACCEPTED SOLUTION

Hello and welcome to the community!

Your query excludes Hugo Weaving, but it does not exclude the paths from the movies that Hugo acted in so for example, you query will return actors who acted in the same movies as Hugo Weaving.

Elaine

View solution in original post

2 REPLIES 2

Hello and welcome to the community!

Your query excludes Hugo Weaving, but it does not exclude the paths from the movies that Hugo acted in so for example, you query will return actors who acted in the same movies as Hugo Weaving.

Elaine

Great explanation!
Now i see that i must be more focused on excluding relation vs the exclusion of some results.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online