0
votes

I'm trying to learn Cypher.

In their online console, I am trying to write a query that will give me all the actors (label "Person") who have played in the same movie as Hugo Weaving.

Based on what I've read so far, this should work:

MATCH (p:Person)-[:ACTED_IN]->(m:Movie)-[:ACTED_IN]->(hugo:Person{Name:"Hugo Weaving"})
RETURN p.Name

However, it is not.

I've also tried:

MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE (:Person{Name:"Hugo Weaving"})-[:ACTED_IN]->(m)
RETURN p.Name

But again - no avail.

Does anyone know what I'm doing wrong?

1

1 Answers

4
votes
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(hugo:Person{name:"Hugo Weaving"})
RETURN p.name

direction of the relation in your query (m:Movie)<-[:ACTED_IN]-(hugo:Person is causing the problem