[英]cypher neo4j - collect a group of nodes
I try to get a collection of nodes in my neo4j project 我尝试在我的neo4j项目中获取节点集合
my db try describe connection between users and movies by rating 我的数据库尝试通过评分描述用户和电影之间的连接
so i link the users to the movie with link "RATED" that have a rating value(1-5) 所以我将用户链接到电影的链接“ RATED”,其评级值为(1-5)
in addition i linked the users with themselves with "SIMILARITY" link 此外,我还通过“相似”链接将用户与自己链接在一起
now i have groups of users that have liked between them 现在我有一群喜欢的用户
i want to see for each group of similarity users:group of movies that liked that movies(liked = rating>=4) 我想为每组相似用户查看:喜欢该电影的电影组(喜欢=评分> = 4)
in this example my result is:Outbreak,Dance With Wolves,Disclosure 在此示例中,我的结果是:爆发,与狼共舞,披露
Now that you have created a direct relationship SIMILAR
between users, you must run a community detection algorithms, so that it defines different groups of users. 现在,您已经在用户之间创建了直接关系
SIMILAR
,您必须运行社区检测算法,以便它定义不同的用户组。 You can run it using apoc.algo
functions using apoc plugin for neo4j. 您可以使用针对Neo4j的apoc插件使用
apoc.algo
函数运行它。
CALL apoc.algo.community(25,['User'],'community','SIMILAR','BOTH',1,10000)
Now that you have defined your user groups with community detection algorithm you can simply query what different groups of users like 现在,您已经使用社区检测算法定义了用户组,您只需查询不同的用户组喜欢什么
//You can also set additional filters when matching movies groups liked
MATCH (user:User)-[rel:LIKED]->(m:Movie) where rel.rating > 3.5
RETURN distinct(user.community) as group,collect(m.title) as movies
Know that this is a very simple version of how you can implement this. 知道这是如何实现此功能的非常简单的版本。 I suggest you check out this graphgist and maybe this video .
我建议您检查这个图表专家 ,也许这个视频 。
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.