简体   繁体   中英

Neo4j and Cypher

I'm learning Neo4j and 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". Here is the question: "In which (released in 1995) Films (and in what roles) has the director of "That Thing You Do" acted?"

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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