neo4j在特定属性

时间:2016-05-17 23:12:44

标签: neo4j

我正在尝试输入两个具有相同结构但属性值不同的CSV。我试图让它只创建属性'name'不匹配的新节点。我认为它正在做的是因为完整的列(我没有使用,它是唯一的,它忽略了MERGE而只是创建一个新节点)。我的代码如下所示:

LOAD CSV FROM 'https://s3.amazonaws.com.../inputSample.csv' AS line
MERGE (e:Executable {system: line[0], location: line[1], name: line[2]})
MERGE (d:Dataset {system: line[3], group: line[4], name: line[5]})
CREATE (d)-[:input]->(e)

LOAD CSV FROM 'https://s3.amazonaws.com/.../sampleOutput.csv' AS line
MERGE (e:Executable {system: line[0], location: line[1], name: line[2]})
MERGE (d:Dataset {system: line[3], group: line[4], name: line[5]})
CREATE (e)-[:output]->(d)

来自输入的示例行:

A   Projects/bmp    bmp loc B   ACCT

输出中的示例行:

B   Projects/asp    asp loc B   ACCT

所以我不希望第二个d:在辅助加载中创建数据集,因为已存在的信息是否有意义?

1 个答案:

答案 0 :(得分:2)

您正尝试使用3个不同的值合并节点。所以

(e:Executable {system: system1, location: location1, name: name1})

(e:Executable {system: system1, location: location2, name: name1})

是不同的。

您应该只指定MERGE的一个属性,然后再设置其他属性:

LOAD CSV FROM 'https://s3.amazonaws.com.../inputSample.csv' AS line
MERGE (e:Executable {name: line[2]})
ON CREATE SET e.system = line[0], e.location = line[1]
MERGE (d:Dataset {name: line[5]})
ON CREATE SET e.system = line[3], d.location = line[4]
CREATE (d)-[:input]->(e)

LOAD CSV FROM 'https://s3.amazonaws.com/.../sampleOutput.csv' AS line
MERGE (e:Executable {name: line[2]})
ON CREATE SET e.system = line[0], e.location = line[1]
MERGE (d:Dataset {name: line[5]})
ON CREATE SET e.system = line[3], d.location = line[4]
CREATE (d)-[:input]->(e)