This cypher query on the neo4j movie dataset will return 822 rows
MATCH (a:Actor)-[:ACTED_IN]->(m:Movie)
WHERE m.year = 2000
AND a.born IS NOT NULL
RETURN DISTINCT a.name AS Actor, a.born AS Born
order by a.born
I modify the query using pattern comprehension below and it returns 15443 rows, but all of them are empty arrays.
MATCH (a:Actor)
with a, [ (a where a.born is not null)-[:ACTED_IN]->(m:Movie where m.year = 2000) | a.name ] as Actors
return Actors
My intent is to return a list of actors just like the first query. What went wrong in the second query?
[UPDATED]
This will give you the distinct actors:
WITH [(a:Actor WHERE a.born IS NOT NULL)-[:ACTED_IN]->(m:Movie WHERE m.year = 2000)|a.name] AS actorList
UNWIND actorList AS actor
RETURN DISTINCT actor