Using movie graph, why does MATCH (n:Person)-[ACTED_IN]->(x:Movie {title:"Stand By Me"}) RETURN n include Rob Reiner

I am sure I am doing something simple wrong here, as I am now to neo4j and cypher. I come from an SQL background.

But I for the life of me cannot figure out why issuing this command against the supplied movie sample data it also returns "Rob Reiner" as "directed" in.. ??

MATCH (n:Person)-[ACTED_IN]->(x:Movie {title:"Stand By Me"}) RETURN n

He did indeed have a small part, but as best as I can tell that is not included in the data (just says directed, not ACTED_IN) and the graph (if I tell it to return x,n instead of just n) includes the relationships, and his is indeed a "directed" relationship, not an acted_in relationship.

I'm sooo confused :-(

This is easy to get wrong for newbies to Cypher Query Language.

You are missing a colon before the relationship type. What you have is the equivalent to:

MATCH (n:Person)-[]->(x:Movie {title:"Stand By Me"}) RETURN n

which matches ANY relationship. ACTED_IN is actually a variable name, the way you wrote it!

What you need is:

MATCH (n:Person)-[:ACTED_IN]->(x:Movie {title:"Stand By Me"}) RETURN n

Note :ACTED_IN and not ACTED_IN

1 Like

O, thank you!!!!!!!!