I have a database of multiple pieces of content all of which have an author relationship.
I want to be able to write a query that returns "recent" content (say 20 posts) but I don't want posts by the same author to appear more than 3 times in the results.
In my case it will be in descending order of creation date (the nodes will have a creation date property). But only a max of 3 posts created by the same author appearing in the results. For a max of 20 (or whatever limit we set)
MATCH (p:Person)-[:POSTED]->(c:Content)
WITH p, c ORDER by c.datePosted DESC
WITH p, collect(c.subject) as theContent
WHERE size(theContent) <= 3
RETURN p.name, theContent