Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-18-2018 01:25 AM
ex : I want to make only one relation "POSTED" outgoing from "NOREVIE" knowing that it ends up by having 4 relations after .
Solved! Go to Solution.
09-18-2018 02:20 AM
Like I said in my first answer, you need to use the pattern MATCH, MATCH, MERGE
during your import.
So you should use this script instead :
LOAD CSV WITH HEADERS FROM 'file:///DOCO.csv' AS DonneursDordre
MATCH (do:DO {id: DonneursDordre.DO_ID}),
(c:Contrat {id: Contrats.Contrat_ID})
MERGE (do)-[:POSTED]->(c)
With this script, you will have only one relationship between a DO
and a Contract
, even if there are many lines in your csv.
Cheers
09-18-2018 01:43 AM
Can you give a little more context ?
For example how do you create your data in Neo4j ?
I assume it's via GraphQl, but what is your schema, what is your resolver for creating those relationship, ...
In Cypher to avoid this, you can use the Merge
:
MATCH (start: ....)
MATCH (end: ....)
MERGE (start)-[:POSTED]->(end)
09-18-2018 02:08 AM
Well I just imported 5 csv files : DO , Contrat , Attrib , DOCO(in which I have DO/Contrat Rleationship )and COAT (in which I have Contrat/Attrib relationship) and I used those two queries for relationships :
Query 1 : DOCO :
LOAD CSV WITH HEADERS FROM 'file:///DOCO.csv' AS DonneursDordre
MATCH(do:DO {id: DonneursDordre.DO_ID}), (c:Contrat {id: Contrats.Contrat_ID})
CREATE (do)-[:POSTED]->(c)
Query 2 : COAT :
LOAD CSV WITH HEADERS FROM 'file:///COAT.csv' AS Contrats
MATCH (c:Contrat {id: Contrats.Contrat_ID}) , (at:Attrib {id: Contrats.Attrib_ID})
CREATE (c)-[:ASSIGNED]->(at)
09-18-2018 02:20 AM
Like I said in my first answer, you need to use the pattern MATCH, MATCH, MERGE
during your import.
So you should use this script instead :
LOAD CSV WITH HEADERS FROM 'file:///DOCO.csv' AS DonneursDordre
MATCH (do:DO {id: DonneursDordre.DO_ID}),
(c:Contrat {id: Contrats.Contrat_ID})
MERGE (do)-[:POSTED]->(c)
With this script, you will have only one relationship between a DO
and a Contract
, even if there are many lines in your csv.
Cheers
09-18-2018 02:32 AM
Can I just update it without reloading ?
Thanks a lot !
09-18-2018 02:46 AM
Nop, you need to delete your database and to reload your scripts
09-18-2018 02:46 AM
Perfect ! Thanks a lot 🙂
All the sessions of the conference are now available online