Neo4j - 只返回一个有多个关系的节点

时间:2016-10-15 18:48:15

标签: spring neo4j cypher

我遇到一个小问题,找出如何返回一个有多个外向关系的节点。

所以我想要的只是显示节点,即使它有多个关系;这是我的疑问:

MATCH total=(n:Employee)-[r:WorkedOn]->(p:Project)
RETURN toFloat(p.total_efficiency) / toFloat(count(p)) as score , n.first_name as name, n.last_name as surname, r.role as role, n.start_date_of_work as startDate, n.experience as experience, 
    n.email as email, n.age as age, collect(p.name) as projects ORDER BY score DESC LIMIT {l}

但是这会返回一个这样的表:

the result generated with Spring boot

如何解决双重'Jari Van Melckebeke'的记录?我只想要一个 我也可以删除'role'属性,但我还是需要Project对象来计算分数......

提前致谢, Jari Van Melckebeke

1 个答案:

答案 0 :(得分:1)

您可以通过两种方法将其折叠为一行。或者,如您所建议的那样,从退货中删除角色,或者返回COLLECT(r.role) as roles