Why isnt Tom Hanks returned in this cypher query?

2019-03-02 02:04发布

问题:

When running this from the Neo4j movie intro

MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) RETURN coActors.name

I was expecting to get "Tom Hanks" back since he also matches the "right side" of the match clause.

How come a node matched on left side not matches on the right side?

回答1:

Relationships that are matched multiple times in a single pattern will not be included. (tom)-[:ACTED_IN]->(m) on the left matches the ACTED_IN relationship from Tom Hanks to the movie. This relationship will not be matched again on the right hand side.

Some more examples of this in the Neo4j Manual- http://neo4j.com/docs/stable/cypherdoc-uniqueness.html



标签: neo4j cypher