Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-27-2020 05:16 AM
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
Solved! Go to Solution.
04-27-2020 06:18 AM
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
04-27-2020 06:18 AM
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
04-27-2020 06:45 AM
Great explanation!
Now i see that i must be more focused on excluding relation vs the exclusion of some results.
All the sessions of the conference are now available online