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