当前位置:网站首页>Neo4j realizes social recommendation (V)

Neo4j realizes social recommendation (V)

2022-06-09 09:29:00 Great for the rest of my life

Catalog

Preface

In the fourth part, the basic social character tags and friend relationship information are established , In this article, we will first add the friends of each character , Enrich our knowledge map and better see the display effect of data 、 Then view common concerns through query statements 、 People you may know 、 Several of my friends have also paid attention to his functions

Realization

Create nodes

Wang Wei's friend : Zhang Jiuling 、 Liguanian 、 meng haoran 、 CEN Shen 、 Yuan Chang 、 Zen master Shenhui 、 Chao Heng
Li Bai already has a friend of Wang Wei among his friends : meng haoran
Create remaining friends : Zhang Jiuling 、 Liguanian 、 CEN Shen 、 Yuan Chang 、 Zen master Shenhui 、 Chao Heng

create (n:SocialUser {
    name:' Zhang Jiuling '}) return n;
create (n:SocialUser {
    name:' Liguanian '}) return n;
create (n:SocialUser {
    name:' CEN Shen '}) return n;
create (n:SocialUser {
    name:' Yuan Chang '}) return n;
create (n:SocialUser {
    name:' Zen master Shenhui '}) return n;
create (n:SocialUser {
    name:' Chao Heng '}) return n;

The above are all Li Bai's friends , So we don't need to filter the pointing relationship , Point directly to the label

match (a:SocialUser {
    name:' Wang wei '}),(b:SocialUser) 
    where b.name in [' Zhang Jiuling ',' Liguanian ',' meng haoran ',' CEN Shen ',' Yuan Chang ',' Zen master Shenhui ',' Chao Heng ']
    merge (a)-[:FRIEND]->(b) 
    return a,b

View results
 Insert picture description here

原网站

版权声明
本文为[Great for the rest of my life]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090851581240.html