Skip to content

Instantly share code, notes, and snippets.

@agrison
Last active September 28, 2015 13:28
Show Gist options
  • Save agrison/c0b9623ddbb654820f2f to your computer and use it in GitHub Desktop.
Save agrison/c0b9623ddbb654820f2f to your computer and use it in GitHub Desktop.
Create a meta model of nodes and relationship already in Neo4J.
MATCH (n1)-[r]->(n2)
WITH labels(n1) AS node1_labels, type(r) AS relation_type, labels(n2) AS node2_labels
UNWIND node1_labels as node1_label
UNWIND node2_labels as node2_label
MERGE (n1:Meta_Node {name: node1_label})
MERGE (n2:Meta_Node {name: node2_label})
MERGE (n1)-[:META_RELATIONSHIP {name:relation_type}]->(n2)
MATCH (node:Meta_Node)-[r]-()
RETURN node, r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment