问题
I have
MATCH (x)-[rels*]->(y)
RETURN extract( r in rels | r.property) as collected
where collected
is a collection of properties of all relationships along the path, such as [null, 4, null, 4]
or [1, 3, 3, 1]
.
How can I further extract from collected
only its unique values?
For example, [null, 4, null, 4]
would change into [null, 4]
回答1:
try this instead:
MATCH (x)-[rels*]->(y)
UNWIND rels AS rel
RETURN COLLECT( distinct rel.property) AS collected
来源:https://stackoverflow.com/questions/26634802/cypher-extract-unique-values-from-collection