我正在尝试返回一个关系属性(称为proportion
)加上该属性的总和,用于与 Neo4j 中的 Cypher 查询匹配的所有关系。我已经做到了这一点:
START alice=node(3)
MATCH p=(alice)<-[r:SUPPORTED_BY]-(n)
RETURN reduce(total=0, rel in relationships(p): total + rel.proportion), sum(r.proportion) AS total;
这将返回:
+-----------------+
| reduced | total |
+-----------------+
| 2 | 2 |
| 1 | 1 |
+-----------------+
我期待的地方:
+-----------------+
| reduced | total |
+-----------------+
| 2 | 3 |
| 1 | 3 |
+-----------------+
作为 Cypher 的初学者,我不确定如何处理这个查询;我显然没有reduce
正确使用。任何意见,将不胜感激。