Cypher: Extract unique values from collection

自古美人都是妖i 提交于 2019-12-11 03:16:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!