我期望此查詢生成7個節點與21個關係。UNWIND與子UNWIND生成錯誤節點和關係
它產生13個節點和6間的關係
WITH [{address: "1", connections: []},
{address: "2",connections: ["1"]},
{address: "3",connections: ["1", "2"]},
{address: "4",connections: ["1", "2", "3"]},
{address: "5",connections: ["1", "2", "3", "4"]},
{address: "6",connections: ["1", "2", "3", "4", "5"]},
{address: "7",connections: ["1", "2", "3", "4", "5", "6"]}] AS seeds
UNWIND seeds AS seed
MERGE (source:Address { address: seed.address })
WITH seed.connections AS connections
UNWIND connections AS connection
MATCH (target:Address) WHERE target.address = connection
MERGE (source)-[:CONNECTS_TO]->(target)
我試圖十幾+變化,包括FOREACH。
我錯了,認爲這是可能的嗎?
謝謝你的回答!將立即測試。 – Geoffrey
100%完美。我嘗試傳遞其他東西,比如'seed.address',顯然,找不到魔法。謝謝! – Geoffrey