Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-26-2022 05:55 AM - edited 07-26-2022 10:46 AM
Create a recommendations sandbox at sandbox.neo4j.com.
For this dataset, write a query that returns one row for every movie in the graph that has at least 10 directors.
It will also return the list of reviewers for each movie.
Each row will contain:
Solved! Go to Solution.
08-07-2022 11:58 PM
Hello @TrevorS 😊
Here is the query:
MATCH (m:Movie)
WHERE size((m)<-[:DIRECTED]-()) >= 10
RETURN m.title AS title, [(m)<-[:DIRECTED]-(d) | d.name] AS directors, [(m)<-[:RATED]-(u) | u.name] AS reviewers;
Here is the screenshot:
Regards,
Cobra
08-17-2022 08:22 AM - edited 08-17-2022 08:41 AM
Hello @TrevorS,
MATCH (n:Movie)
WHERE size((n)<-[:DIRECTED]-()) >= 10
WITH n { .title,
directors: [ (n)<-[:DIRECTED]-(p) | p.name],
reviewers: [ (n)<-[:RATED]-(g) | g.name]
}
RETURN n.title AS title, n.directors AS directors, n.reviewers AS reviewers
I've just started learning Neo4j and I'm currently completing the Intermediate Cypher Queries course when I saw the challenge and decided to share this.
Regards,
L
08-07-2022 11:58 PM
Hello @TrevorS 😊
Here is the query:
MATCH (m:Movie)
WHERE size((m)<-[:DIRECTED]-()) >= 10
RETURN m.title AS title, [(m)<-[:DIRECTED]-(d) | d.name] AS directors, [(m)<-[:RATED]-(u) | u.name] AS reviewers;
Here is the screenshot:
Regards,
Cobra
08-17-2022 08:22 AM - edited 08-17-2022 08:41 AM
Hello @TrevorS,
MATCH (n:Movie)
WHERE size((n)<-[:DIRECTED]-()) >= 10
WITH n { .title,
directors: [ (n)<-[:DIRECTED]-(p) | p.name],
reviewers: [ (n)<-[:RATED]-(g) | g.name]
}
RETURN n.title AS title, n.directors AS directors, n.reviewers AS reviewers
I've just started learning Neo4j and I'm currently completing the Intermediate Cypher Queries course when I saw the challenge and decided to share this.
Regards,
L
08-17-2022 09:24 AM
08-17-2022 02:00 PM
These all are the same idea.
match (m:Movie)<-[:DIRECTED]-(p)
with m, count(p) as count
where count > 9
match (m)<-[:DIRECTED]-(p)
with m, collect(p.name) as directors
match (m)<-[:RATED]-(u)
return m.title as title, directors, collect(u.name) as reviewers
Is it any better?
All the sessions of the conference are now available online