Neo4j - 用标签计算节点 [英] Neo4j - Counting Nodes with Labels

查看:32
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆