Consider this cypher query
MATCH (a : User)-[c : Commented]->(b) RETURN DISTINCT a.username AS
username, b.postId AS postId, COLLECT({commentBody : c.comments,
commentedOn : c.time})[0..5] AS commentData LIMIT 20;
query returns me 'c' starting from 1st and limits it to 5. How can I fetch last five 'c' and then order them by commentedOn. Note** count of number of relations between 'a' and 'c' is not known, could be 1 could be 1000.
What I am trying to achieve is, return up to 20 'a' nodes with last to last-5 related relations 'c' for that path. for eg. your instagram home page could have 20 posts and each one of them may have many comments under one post collection, right? I am able to achieve till here, I can collect first 5 relations 'c', my question here is how do I collect last 5 relations 'c' given I have to match 20 'a' nodes.