Why these differences in Query?

Hi,

in "intermediate cypher" I created two queries:

MATCH (m:Movie)
WHERE m.year = 2015
RETURN m.title,
[(dir:Person)-[:DIRECTED]->(m) | dir.name] AS directors
-> Returns 180 People

MATCH (m:Movie) <-[:DIRECTED] - (p:Person)
WHERE m.year = 2015
RETURN m.title, collect(p.name) AS directors
-> Returns 178 People

Why does the first Query include empty lists (two movies with as directors while the second does not?

Is there a command for whether a property has more than one entry?

Bye

Michael

List comprehension will return an empty list when no matches are found. Matching followed by collecting will not return an empty list when there is not a match and you are grouping.

1 Like

What Gary said :+1:.

collect() considerations - Any null values are ignored and will not be added to the list.

1 Like