Last active
October 8, 2020 17:33
-
-
Save latant/37930417c5f557427847f6feca7e6816 to your computer and use it in GitHub Desktop.
Loading distinct nodes and relationships with patterns in Neo4J 4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call { | |
match p=()--()--() return | |
reduce(ns = [], n in collect(nodes(p)) | ns + n) as ns, | |
reduce(rs = [], r in collect(relationships(p)) | rs + r) as rs | |
} | |
call { with ns unwind ns as n return collect(distinct n) as nodes } | |
call { with rs unwind rs as r return collect(distinct r) as relationships } | |
return {nodes: nodes, relationships: relationships} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment