为了限制通过Neo4j图形数据库的遍历,我从子图中收集分数。想象一下(简化)
MATCH (a)-[:r1 {prop1:123}]->()-[]->()-[]->()-[]->(b {prop2:456})
WITH b,b.prop2*r1.prop1 as score ORDER BY score DESC LIMIT 10
WITH COLLECT ([b,score]) AS bscore
到目前为止,这么好。为了避免长遍历,我想将下一个匹配限制为存储在bscore中的节点b并对bscore [1]中的分数求和,但是我找不到正确的语法。甚至想知道它是否可能在密码中。从概念上讲,我想这样做:
MATCH bscore[0]-[:r2]->(c)
RETURN c, SUM(bscore[1])
高度赞赏任何提示/指示。
答案 0 :(得分:2)
你可以这样做吗?
MATCH (a)-[:r1 {prop1:123}]->()-[]->()-[]->()-[]->(b {prop2:456})
WITH b,b.prop2*r1.prop1 as score ORDER BY score DESC LIMIT 10
MATCH b-[:r2]->(c)
RETURN c, sum(score)