我正在尝试创建一个位置,创建一个会议,按索引查找两个人,然后将它们连接在一起。首先,我因为在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)
答案 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)