Neo4j-计算和根据关系属性设置节点属性 [英] Neo4j - calculate & set node property based on relation property

查看:823
本文介绍了Neo4j-计算和根据关系属性设置节点属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以计算&设置(更新)基于节点属性的关系属性(传入和传出)? 在我的示例中,我想根据用户的关系持续时间(int)除以计数(int)来计算用户的个人强度因子"(平均数).

I want to know, if it's possible to calculate & set (update) a node property based relation properties (incoming&outgoing)? In my example, I would like to calculate an user personal "strength factor" (Kind of average) based on his relationships duration (int) divided by the count (int).

感谢您的提前帮助,

欢呼

推荐答案

是的,有可能.唯一的技巧是必须使用 WITH 首先执行汇总(用于计算平均值):

Yes, it's possible. The only trick is that you have to use WITH to first perform the aggregation (for calculating the average):

MATCH (n)-[r:RELTYPE]->()
WITH n, avg(r.duration) AS strength
SET n.strength = strength

这篇关于Neo4j-计算和根据关系属性设置节点属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆