简体   繁体   中英

Neo4j Client Creating Relationship between two existing Nodes

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.

I think this is wat you want;

MATCH (n1), (n2)
WHERE ID(n1) = 1 AND ID(n2) = 2
CREATE (n1)-[r:RELATION]->(n2) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM