I need to group the data from a neo4j database and then to filter out everything except the top n
records of every group.
Example:
I have two node
I tried to achieve your desired results and failed.
So, my guess - this one is impossible with pure cypher.
What is the problem? Cypher is considering everything as a paths. And actually is doing traverse.
Trying to group results and then execute filter on each group means that cypher should somehow branch it traversing at some points. But Cypher executed filter on all results, because they are considered as collection of different paths.
My suggestion - create several queries, that achieves desired functionality, and implement some client-side logic.