简体   繁体   English

Neo4j中的关系属性

[英]Relationship properties in Neo4j

I have a problem with relations on Neo4j. 我对Neo4j的关系有疑问。 I have 3 files with the .csv extension to be loaded into Neo4j. 我有3个扩展名为.csv的文件可以加载到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: 这些文件是:forum_0.csv和person_0.csv,它们具有以下标题:

idForum|titleForum|creationDateForum (forum_0.csv) idForum | titleForum | creationDateForum(forum_0.csv)

idPerson|firstNamePerson|lastNamePerson| idPerson | firstNamePerson | lastNamePerson | ... (person_0.csv) ...(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 ) 为此,我需要加载第三个文件“ forum_hasMember_person_0.csv”(此文件具有此标头: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? 如何使用“ joinDateFHMP”属性创建FOR_HASMEMBER_PRS关系? 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: 我喜欢在关系上放一个标识符,然后使用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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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