cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Create many relationships at one times

Hi All
I want create relationships between a (a1,a2,a3...) and b (b1,b2,b3...),
where relationships are c (c1,c2,c3...).
(like a1-[:c1]->b1, a2-[:c2]->b2, a3-[:c3]->b3...)
How can I do ?

LOAD CSV WITH HEADERS FROM "file:///abc.csv" AS line
MATCH ( a: ee { ee_id: line.from } )
MATCH ( b: ee { ee_id: line.to } )
MATCH ( c: r { r_id :line.id } )
MERGE (a)-[ :c]->(b)

1 REPLY 1

Hi yasinlyu,

welcome in the Neo4j community!

Shall the relationships be of variable "type", i.e. label? What do you mean by "[:c]"? Do you want the relationship to just have the properties of c?

If you "simply" have trouble loading several edges with same type, have a look here: How to create a relation from two columns in one table? - Neo4j Graph Platform / Cypher - Neo4j Onli...

If you want variable label relationships, have a look here: apoc.refactor.setType - APOC Documentation (neo4j.com)

If you have further problems, do not hesitate to ask.

Hope this helps.
Regards,
Elena