I am trying to return a set of nodes where there is more than n outgoing relationships of the same kind. The specific use case is given a set of movies which actors have contributed to more than one of those movies.
I have tried multiple methods of COUNTing
and SIZE
, but cannot figure out whether this is even possible in Neo4J
MATCH (cw:CreativeWork) WHERE cw.officialTitle IN ['Antz', 'The Specialist ']
MATCH (p:Person) WHERE SIZE((p)-[:contributedTo]-(cw)) > 1
RETURN p, cw
This will return the two Creative Works specified and all the people who have contributed to the title, based on the relationship :contributedTo
. Two actors in the list have contributed to both titles, and I am interested in returning just those two.
This query for example returns no results:
MATCH (cw:CreativeWork) WHERE cw.officialTitle IN ['Antz', 'The Specialist ']
MATCH (p:Person) WHERE SIZE((p)-[:contributedTo]-(cw)) > 1
RETURN p, cw