How can I quickly count the number of "posts" made by one person and group them by person in a cypher query?
Basically I have message label nodes and users that posted (Relationship) those messages. I want to count the number of messages posted by each user.
Its a group messages by sender ID and count the number of messages per user.
Here is what I have so far...
START n=node(*) MATCH (u:User)-[r:Posted]->(m:Message)
RETURN u, r, count(r)
ORDER BY count(r)
LIMIT 10
n
the author andm
the post? If the relationship,r
, is:POSTED
why do you need to equaten.id = m.sender_id
? If what you have really something like this...(a:Author)-[r:POSTED]->(m:Message)
? – Dave Bennettstart n=node(*)
!! Esp. not with an unrelated node, it will create a huge cartesian product for every node in your graph. – Michael Hunger