Reputation: 30
I have tried to create a relationship between two nodes while using Unwind on existing relationships (I am trying to migrate from a previous database)
So Links = relationships which hold the Id of each node on target and source (ID is different from the neo4j id)
The Cypher does not return any error and I do manage to add the nodes but for some reason that I cannot understand why the relationships between nodes are not getting created.
I am using this Cypher:
graphClient.Cypher
.Unwind(graph.Links, "singleLink")
.Match("(firstNode:Node{id: singleLink.Source , projectId: {innerProjectId}})", "(secondNode:Node{id: singleLink.Target , project: {innerProjectId}})")
.WithParam("innerProjectId",project.Id)
.Create("(firstNode:Node)-[:ConnectedTo{source: singleLink.Source, target: singleLink.Target}]->(secondNode:Node)")
.ExecuteWithoutResults();
Thanks a lot.
Upvotes: 0
Views: 556
Reputation: 1
I think this is wat you want;
MATCH (n1), (n2)
WHERE ID(n1) = 1 AND ID(n2) = 2
CREATE (n1)-[r:RELATION]->(n2)
Upvotes: 0