2014-10-09 157 views
0

對於數據(如下圖),我的查詢看起來像這樣:Neo4j的深複製節點

MATCH p = (ob:Obiect)<--(w:Word { value:'game' })-[*]-(x) RETURN {id: id(x), value: x.value} 

CREATE (w0:Obiect { value : 'Obiect' }) 
CREATE (w1:Word { value:'game' }) 
CREATE (w2:Word { value:'unreal' }) 
CREATE (w3:Word { value:'a' }) 
CREATE (w4:Word { value:'b'}) 
CREATE (w5:Word { value:'c' }) 
CREATE (w6:Word { value:'d'}) 
CREATE (w1)-[:IS]->(w0) 
CREATE (w2)-[:IS]->(w1) 
CREATE (w3)-[:HAS]->(w2) 
CREATE (w4)-[:HAS]->(w3) 
CREATE (w5)-[:HAS]->(w4) 
CREATE (w6)-[:HAS]->(w5) 
CREATE (w6)-[:HAS]->(w3) 

如果關係(值:d) - >(值:a)不存在,那麼它的好和我的結果是這樣的:

id 4070 value unreal 
id 4071 value a 
id 4072 value b 
id 4073 value c 
id 4074 value d 

但如果關係存在,那麼我有重複的節點(下面)。問題是如何避免這個問題?

id 4063 value unreal 
id 4064 value a 
id 4065 value b 
id 4066 value c 
id 4067 value d 
id 4064 value a 
id 4067 value d 
id 4066 value c 
id 4065 value b 
id 4064 value a 

回答