Getting top n records for each group in neo4j

后端 未结 3 915
心在旅途
心在旅途 2021-02-15 03:15

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

3条回答
  •  遥遥无期
    2021-02-15 03:50

    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.

提交回复
热议问题