我需要一个密码查询,它同时检索两条边的权重。这是我的尝试:
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
对于更新和查看文件的每个用户,结果包含两行。但是,我希望结果在一行。例如:user:x - 更新:12 - 已查看:15
我该怎么做?
答案 0 :(得分:0)
更新:
尝试:
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