下面的cypher命令提供了所有节点的列表
match(n) return distinct labels(n), count(*)
我想做同样的事情但是对于一个节点,例如
match(p:Person {name: "dave"} return distinct labels(n), count(*)
我已经尝试了这个,但它只返回一个
的计数我需要一个包含此人的标签总数的列表
**labels(n)** **count(*)**
['Address'] 2
['jobs'] 1
['cars'] 3
答案 0 :(得分:1)
match(p:Person {name: "dave"} return distinct labels(n), count(*)
计算行数(没有聚合,它将始终为1)。您将标签作为数组返回,因此您真正想要的是数组长度
match(n) return distinct labels(n), SIZE(LABELS(n))
根据您的问题,我认为您实际上想要解开像这样的标签
match(n) UNWIND LABELS(n) as label WITH label RETURN DISTINCT label, count(label)
答案 1 :(得分:0)
感谢您的帮助,但这仍然会返回1.我刚刚弄清楚如何得到我需要的东西:
Match (p:Person{name:"dave"})-[*]->(c) return distinct labels(c), count(*)