I have a few Realtionships in Neo4J with the label "[r:Absatraction]". They all have a Property on them like "SysML:refine" or "SysML:trace" or "SysML:verify". These "Abstractions connect differently labeled nodes. Now I want Neo4j to replace the Label "Abstraction" with the labels from the "SysML" Property. So that on the graph one can see "[r:refine],[r:verify]...". I tried: apoc.create.addLabels, but it only seems to work for nodes. Is there a way to do that?
0
votes
2 Answers
0
votes
In neo4j terminology, a relationship must have a single "type" -- not an optional set of "labels" (which are only for nodes). Furthermore, a relationship's type cannot be changed.
So, to do what you want, you'd have to create new relationships (with the desired types) and delete the old ones.
For example, here's is how you can use the APOC procedure apoc.create.relationship to create new relationships with the right types (and with the same properties as the old relationships except for SysML), and delete the old relationships:
MATCH (a:Foo)-[r:Abstraction]->(b:Foo)
CALL apoc.create.relationship(a, r.SysML, apoc.map.removeKey(PROPERTIES(r), 'SysML'), b) YIELD rel
DELETE r
RETURN rel