Reputation: 23
Using Movie data set, how can you find the actors acting as more than one role in a movie.
Upvotes: 0
Views: 531
Reputation: 30397
In the movies db, roles
is a list property on :ACTED_IN relationships, so all we need to do is find that particular pattern where the roles
list is greater than 1:
MATCH (a:Person)-[r:ACTED_IN]-(m:Movie)
WITH a, r.roles as roles, m
WHERE size(roles) > 1
RETURN a, roles, m
Upvotes: 2
Reputation: 6524
Ok, you can do this more ways... since roles are saved as relationships you can just check, who has more than one relationship to a movie.
MATCH (a:Person)-[r]-(m:Movie)
WITH a,m,collect(type(r)) as rels where length(rels) > 1
RETURN a,rels,m
Upvotes: -1