如何计算Neo4j图中节点类型的数量? [英] How to count the numbers of node types in the Neo4j graph?

查看:1293
本文介绍了如何计算Neo4j图中节点类型的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MATCH (p:Product), (s:Student), (b:Boy), (a:Attribute)
RETURN count(distinct(p)), count(distinct(s)), count(distinct(b)), count(distinct(a))

我想知道使用此查询在图形中每个节点类型有多少计数.但是,Neo4j浏览器给出警告,说该查询产生笛卡尔积.有没有更好的方法来编写查询?

I want to know how many counts of each node types in the graph using this query. However, the Neo4j Browser gives a warning saying that this query produces a cartesian product. Is there a better way to write the query?

推荐答案

要获取数据库的各种统计信息,包括每个标签的节点数,可以使用APOC函数

To get a variety of statistics for your DB, including a count of the number of nodes for every label, you can use the APOC function apoc.meta.stats.

以下查询仅获取标签节点计数,将标签名称的映射返回到节点计数:

The following query gets just the label node counts, returning a map of label names to node counts:

CALL apoc.meta.stats() YIELD labels
RETURN labels;

这篇关于如何计算Neo4j图中节点类型的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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