简体   繁体   English

Neo4j 和 Cypher

[英]Neo4j and Cypher

I'm learning Neo4j and Cypher.我正在学习 Neo4j 和 Cypher。 How do I get this to work so that the answer is just the title and the name of the director?我如何让它起作用,以便答案只是导演的头衔和姓名? The database is the Neo4j Movie from " Graph Academy".数据库是来自“Graph Academy”的 Neo4j Movie。 Here is the question: "In which (released in 1995) Films (and in what roles) has the director of "That Thing You Do" acted?"这里的问题是:“《你做的那件事》的导演在哪些(1995 年上映的)电影中(以什么角色)出演过?”

And here is what I have so far:这是我到目前为止所拥有的:

MATCH (p:Person)->(m:Movie {title: 'That thing you do'})->[:ACTED_IN |DIRECTED] WITH date(m.released = 1995) RETURN m.title as Movie, p.role as Roles

It is often helpful to break a complex query like this into steps:将这样的复杂查询分解为几个步骤通常很有帮助:

Find the Movie "That Thing You Do"...找到电影“你做的那件事”......

MATCH (thatthingyoudo:Movie {title: "That Thing You Do"}) 
RETURN thatthingyoudo

...find the director of that movie ...找到那部电影的导演

MATCH (thatthingyoudo:Movie {title: "That Thing You Do"})-[:DIRECTED]-(director:Person) 
RETURN director

...find movies this director has acted in ...找到这位导演演过的电影

MATCH (thatthingyoudo:Movie {title: "That Thing You Do"})-[:DIRECTED]-(director:Person)-[:ACTED_IN]-(m:Movie) 
RETURN m

...don't care about all the movies, just the ones in 1995 ...不要关心所有的电影,只关心 1995 年的电影

MATCH (thatthingyoudo:Movie {title: "That Thing You Do"})-[:DIRECTED]-(director:Person)-[:ACTED_IN]-(m:Movie {released:1995}) 
RETURN m

...finally, just extract the director's name and title of the moview and roles maybe, ...最后,只要提取导演的名字和电影的标题和角色,也许,

MATCH (thatthingyoudo:Movie {title: "That Thing You Do"})-[:DIRECTED]-(director:Person)-[actedIn:ACTED_IN]-(m:Movie {released:1995}) 
RETURN m.title, director.name, actedIn.roles

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM