這可能是一種愚蠢的方式。我想創建節點鏈,可能是成千上萬人以下列形式:從一個查詢攜帶變量到另一個查詢以創建帶有密碼的鏈接節點
(n0)-[r0]->(n1)-[r1]->(n2)...
我已經通過編程生成的暗號這看起來是這樣的:
MERGE (n0:Person)-[r0:RelType]->(n1:Person)
WITH n1 MERGE (n1:Person)-[r1:RelType]->(n2:Person)
WITH n2 MERGE (n2:Person)-[r2:RelType]->(n3:Person)
WITH n3 MERGE (n3:Person)-[r3:RelType]->(n4:Person)
WITH n4 MERGE (n4:Person)-[r4:RelType]->(n5:Person)
...
我然後複製上面的查詢中粘貼Neo4j的Web控制檯就跑,但它給了以下錯誤:
Can't create node `n1` with labels or properties here. The variable is already declared in this context
我的理解(或者我不?),我們不能用MERGE
內WITH
。另外我知道我們可以批量導入節點,使用Neo4jImport
從CSV關係。 但我只是好奇,如果我們可以生成一堆密碼複製粘貼到neo4j Web控制檯並創建所需的圖形。