Number of distinct elements in an array property

Is it possible to calculate a number of distinct elements of an array property per each node?

yes if you get the elements, then you can use count(distinct e)

for your example:

match (p:Person)
where p.id in ["1", "2"]
unwind p.embed as e
return p, count(distinct e)

or you can use size(apoc.coll.toSet(p.embed))

1 Like