Neo4j-计数带有标签的节点 [英] Neo4j - Counting Nodes with Labels
本文介绍了Neo4j-计数带有标签的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个查询,该查询计算数据集中每个标签有多少个节点.例如:
I'd like a query that counts how many nodes have each label in the dataset. For instance:
标签A 100 标签B 200
LabelA 100 LabelB 200
我可以使用
MATCH (n:LabelA) return count(n);
但是,我想在一个命令中为每个标签执行此操作.
But, I'd like to do it for every label in one command.
推荐答案
尝试类似的方法
MATCH (n)
RETURN DISTINCT count(labels(n)), labels(n);
这将返回第一列中标签的总和,第二列中标签的名称.
This will return the sum of the labels in the first column and the label name in the second.
这篇关于Neo4j-计数带有标签的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文