而 Party 怎么可以少了 Tony 呢?难道是他的惊喜生日 Party , Opps,我们是不是不应该告诉他?
信息流我在之前写过《基于图技术的推荐系统实现方法》 , 其中讲述了在图谱上实现现代推荐系统中基于内容和协同的过滤,而类似的原理应用在社交网络可以实现个性推荐信息流 。
好友参与的内容最简单的信息流 , 可能就是朋友圈、微博 feed 上刷到的关注的人创建、参与的内容 。先不考虑排序的问题,这些内容一定是:
- 一定时间段内好友创建的内容
- 一定时间段内好友评论的内容
MATCH (feed_owner:player)-[:`follow`]-(friend:player) WHERE id(feed_owner) == "player100"OPTIONAL MATCH (friend:player)-[newly_commented:commented_at]->(:post)<-[:created_post]-(feed_owner:player)WHERE newly_commented.post_time > timestamp("2010-01-01 00:00:00")OPTIONAL MATCH (friend:player)-[newly_created:created_post]->(po:post)WHERE newly_created.post_time > timestamp("2010-01-01 00:00:00")WITH DISTINCT friend,collect(DISTINCT po.post.title) + collect("comment of " + dst(newly_commented))AS feeds WHERE size(feeds) > 0RETURN friend.player.name, feeds
feeds
Boris Diaw
["I love you, Mom", "comment of post11"]
Marco Belinelli
["my best friend, tom", "comment of post11"]
Danny Green
["comment of post1"]
Tiago Splitter
["comment of post1"]
Dejounte Murray
["comment of post11"]
Tony Parker
["I can swim"]
LaMarcus Aldridge
["I hate coriander", "comment of post11", "comment of post1"]
Manu Ginobili
["my best friend, jerry", "comment of post11", "comment of post11"]
于是,我们可以把这些评论、文章呈现到用户的 feed 。
一样的,我们来看看可视化效果 。输出所有查到的路径:
MATCH p=(feed_owner:player)-[:`follow`]-(friend:player) WHERE id(feed_owner) == "player100"OPTIONAL MATCH p_comment=(friend:player)-[newly_commented:commented_at]->(:post)<-[:created_post]-(feed_owner:player)WHERE newly_commented.post_time > timestamp("2010-01-01 00:00:00")OPTIONAL MATCH p_post=(friend:player)-[newly_created:created_post]->(po:post)WHERE newly_created.post_time > timestamp("2010-01-01 00:00:00")RETURN p, p_comment, p_post
在 Explorer 上进行渲染,选择 “神经网络” 这个布局,可以很清晰地看出这些红色的文章节点,还有代表评论的边 。附近好友的内容我们再进一步,把地理信息考虑进来 , 获取那些在指定距离范围内的朋友的相关内容 。
这里 , 我们用到了 NebulaGraph 的 GeoSpatial 地理功能,ST_Distance(home.address.geo_point, friend_addr.address.geo_point) AS distance WHERE distance < 1000000 的约束条件帮我们表达了距离的限制 。
MATCH (home:address)-[:lived_in]-(feed_owner:player)-[:`follow`]-(friend:player)-[:lived_in]-(friend_addr:address)WHERE id(feed_owner) == "player100"WITH feed_owner, friend, ST_Distance(home.address.geo_point, friend_addr.address.geo_point) AS distance WHERE distance < 1000000OPTIONAL MATCH (friend:player)-[newly_commented:commented_at]->(:post)<-[:created_post]-(feed_owner:player)WHERE newly_commented.post_time > timestamp("2010-01-01 00:00:00")OPTIONAL MATCH (friend:player)-[newly_created:created_post]->(po:post)WHERE newly_created.post_time > timestamp("2010-01-01 00:00:00")WITH DISTINCT friend,collect(DISTINCT po.post.title) + collect("comment of " + dst(newly_commented))AS feeds WHERE size(feeds) > 0RETURN friend.player.name, feeds
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 客户欠货款不认账要怎么办理 客户欠货款不认账要怎么办
- 苹果13屏幕发黄怎么回事儿 苹果13屏幕发黄怎么回事
- 怎么看微信是哪一年注册的账号 怎么看微信是哪一年注册的
- 逃税86万怎么惩处他人 逃税86万怎么惩处
- 孩子学习没耐心怎么办 孩子没耐心怎么办培养
- 抖音极速版怎么发视频作品 抖音极速版怎么发视频
- 孩子上高一静不下心学习怎么办
- 小孩子静不下心学习怎么办 孩子静不下心来学东西怎么办
- 新买的车库门遥控器怎么对码 车库门遥控器怎么对码
- 电脑版qq音乐怎么看等级 qq音乐怎么看等级