在cypher命令期间未连接的节点

时间:2015-09-18 18:15:36

标签: neo4j cypher

我正在尝试创建一个位置,创建一个会议,按索引查找两个人,然后将它们连接在一起。首先,我因为在Merge和Match之间没有WITH而大喊大叫,但是当查询运行时,我有2个人连接到一个聚会,但该位置是一个空节点,并且位置节点在空间中浮动。关于我做错了什么想法?

MERGE (location:Location{location_name:"Starbucks", address:"300 S Main St", city: "Ann Arbor", state: "MI", zip_code:"48104", phone_number:"", web_address:""}) WITH location

MERGE(m:Meetup{meet_date:"2015-09-17", meet_time:"14:00:00",status:"Pending",did_happen:""})
WITH m

MATCH(p1:Person{username:"wkolcz"})

MATCH(p2:Person{username:"stubbe"})

MERGE (p1)-[:REQUESTED]->(m)<-[:WAS_REQUESTED]-(p2)

MERGE (m)-[:MEETUP_AT]->(location)-[:HOSTED_MEETUP]->(m)

1 个答案:

答案 0 :(得分:2)

首先,您需要更改MATCH个节点上的两个Person语句以使用MERGE(除非图中已存在这些节点)。

其次,在WITH子句中,您必须添加location。您必须在WITH语句中包含要将其带入查询的下一部分的任何变量。有关WITH here

的更多信息

以下是完整查询:

MERGE (location:Location{location_name:"Starbucks", address:"300 S Main St", city: "Ann Arbor", state: "MI", zip_code:"48104", phone_number:"", web_address:""}) WITH location
MERGE (m:Meetup{meet_date:"2015-09-17", meet_time:"14:00:00",status:"Pending",did_happen:""})
WITH m, location
MERGE (p1:Person{username:"wkolcz"})
MERGE (p2:Person{username:"stubbe"})
MERGE (p1)-[:REQUESTED]->(m)<-[:WAS_REQUESTED]-(p2)
MERGE (m)-[:MEETUP_AT]->(location)-[:HOSTED_MEETUP]->(m)