[英]Get relationship node from 2 edges in 1 cypher query
I need a cypher query that retrieves the weight of two edges at the same time. 我需要一个密码查询,可同时检索两个边缘的权重。 This is my attempt:
这是我的尝试:
MATCH (n:User)-[r:VIEWED|UPDATED]->(f:File) WHERE f.id IN 'some_id','another_id'] RETURN n, r.weight, ORDER BY r.weight DESC
The result contains two lines for each user who updated and viewed the file. 对于每个更新和查看文件的用户,结果包含两行。 However, I want the result in one line.
但是,我希望结果在一行中。 For example: user: x - updated: 12 - viewed:15
例如:用户:x-更新时间:12-浏览次数:15
How can I do this? 我怎样才能做到这一点?
MATCH (n:User)-[r:VIEWED|UPDATED]->(f:File)
WHERE f.id IN ['some_id','another_id']
RETURN n, collect(type(r)), collect(r.weight)
UPDATED: 更新:
try: 尝试:
MATCH (f:File)
OPTIONAL MATCH (n:User)-[r1:VIEWED]->(f:File)
OPTIONAL MATCH (n:User)-[r2:UPDATED]->(f:File)
where f.id IN ['some_id','another_id']
return n,
sum(r1.weight) as totalViewedWeight,
sum(r2.weight) as totalUpdatedWeight
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.