Reputation: 59
I'm trying to create one directed relationship if user_1<-FOLLOWS-> user_2. When I'm using the following cypher it creates those relationships duplicated as user1-[FOLLOWS]->user2 and user1<-[:FOLLOWS]-user2.
LOAD CSV with headers FROM "file:///a.csv" AS profile FIELDTERMINATOR';'
MATCH (n1:Profile {id:trim(profile.fromId)})
MATCH (n2:Profile {id:trim(profile.ToId)})
MERGE (n1)-[:FOLLOWS]->(n2);
Have you got any ideas instead of creating double time the same type of relationship?
Upvotes: 0
Views: 297
Reputation: 510
There is no Undirected graph support in neo4j . But there is support for pattern match without direction .i.e : you can query like ,
MATCH (n1)-[:FOLLOWS]-(n2) or MERGE (n1)-[:FOLLOWS]-(n2)
.
So , there is no need for undirected graph when there is scope for matching without giving direction.
so in your case , if you do like this, it wont create duplicate relations
MATCH (n1:Profile {id:trim(profile.fromId)})
MATCH (n2:Profile {id:trim(profile.ToId)})
MERGE (n1)-[:FOLLOWS]-(n2)
Upvotes: 1