I'd like a query that counts how many nodes have each label in the dataset. For instance:
LabelA 100 LabelB 200
I can do this for each individual label with something like
MATCH (n:LabelA) return count(n);
But, I'd like to do it for every label in one command.
The limitation is currently 2^35, so approximately 34 billion nodes.
Relationships provide directed, named semantic connections between two nodes. A relationship always has a direction, a type, a start node, and an end node.
With UNWIND , you can transform any list back into individual rows. These lists can be parameters that were passed in, previously collect -ed result or other list expressions. One common usage of unwind is to create distinct lists. Another is to create data from parameter lists that are provided to the query.
Try something like this
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.
A quick alternative here, for single labels only, APOC Procedures offers a quick means of using the counts store to get the counts:
CALL apoc.meta.stats() YIELD labels
RETURN labels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With