mowlana
mowlana

Reputation: 23

Cypher: find actors having more than one role in a movie

Using Movie data set, how can you find the actors acting as more than one role in a movie.

Upvotes: 0

Views: 531

Answers (2)

InverseFalcon
InverseFalcon

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

Tomaž Bratanič
Tomaž Bratanič

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

Related Questions