0
我對neo4j比較新,我在合併節點時遇到了一些問題。也許我有錯誤的概念,但這裏是問題陳述和我試圖做的事情。Neo4J基於標籤值合併兩個節點
問題描述:通過根據屬性的值爲每個用戶查找匹配來創建圖表。
Person-> id: user1, movie: lord of the rings
Person-> id: user1, movie: alice in wonderland
Person-> id: user2, movie: star wars
Movie-> name: lord of the rings, genre: Fantasy
Movie-> name: alice in wonderland, genre: Fantasy
Movie-> name: star wars, genre: Fantasy
我想爲我的輸出是:
user1 -> lord of the rings
-> alice in wonderland
user2 -> star wars
相反,我所得到的是:
user1 -> lord of the rings
user1 -> alice in wonderland
user2 -> star wars
這是我到目前爲止已經試過:
MATCH (a:user),(b:movie)
where a.movieName = b.name
MERGE (a)-[r:matches]->(b)
RETURN r
理想情況下,我想能夠創建一個圖表,我可以看到用戶對不同電影的所有連接作爲一對多連接。我希望這是明確的!關於我做錯什麼的想法。
所以我是否需要指定它匹配的內容?我的意思是它怎麼知道要匹配什麼? – Roshini
您必須在創建數據集時設置關係,而不必在您的問題查詢中創建外鍵關係。 – Supamiu
我看到工作!非常感謝。 – Roshini