简体   繁体   中英

Relationship properties in Neo4j

I have a problem with relations on Neo4j. I have 3 files with the .csv extension to be loaded into Neo4j. The first two files are nodes that I already and successful created. The files are: forum_0.csv & person_0.csv and they got this headers:

idForum|titleForum|creationDateForum (forum_0.csv)

idPerson|firstNamePerson|lastNamePerson| ... (person_0.csv)

I successful create the two nodes but now I need to create a relation between these nodes. For that I need to load the third file, forum_hasMember_person_0.csv (and this file got this header: idForum|idPerson|joinDateFHMP )

and my problem is at this point. I load the third file with this code:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM ".../forum_has_Member_person_0.csv" AS row
FIELDTERMINATOR "|"
MATCH (forum:Forum(idForum: row.idForum))
MATCH (person:Person(idPerson: row.idPerson))
MERGE (forum)-[:FOR_HASMEMBER_PRS]->(person);

How can I create the FOR_HASMEMBER_PRS relation with "joinDateFHMP" property? It's the only thing left on the relationship creation. How can I solve this?

I like putting an identifier on the relationship and then using SET:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM ".../forum_has_Member_person_0.csv" AS row
FIELDTERMINATOR "|"
MATCH (forum:Forum {idForum: row.idForum})
MATCH (person:Person {idPerson: row.idPerson})
MERGE (forum)-[r:FOR_HASMEMBER_PRS]->(person)
SET r.joinDateFHMP = row.joinDateFHMP;

Does this work for you? I have also fixed some typos in your question's query.

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM ".../forum_has_Member_person_0.csv" AS row
FIELDTERMINATOR "|"
MATCH (forum:Forum {idForum: row.idForum})
MATCH (person:Person {idPerson: row.idPerson})
MERGE (forum)-[:FOR_HASMEMBER_PRS {joinDateFHMP: row.joinDateFHMP}]->(person);

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