I thought this would be very easy, because i have a typical graph use case: Expand a node.
This is easy if there are no additional requirements:
MATCH (s:Entity)-[]-(dest) WHERE s._id = 'xxx'
RETURN dest
Problem Nr.1: sometimes there are many children so i want to limit the return count!
MATCH (s:Entity)-[]-(dest) WHERE s._id = 'xxx'
RETURN dest
LIMIT 100
Additional requirement: Return all children ids of the children childrens!
MATCH (s:Entity)-[]-(dest) WHERE s._id = 'xxx'
WITH collect(dest) as childrenSource
LIMIT 100
MATCH (childrenSource)-[]-(childDestination)
RETURN childrenSource as expandNode, collect(childDestination) as childrenIds
LIMIT 100
Problem 2: The limits are in the wrong place, because collect already did the collection before the limit.
Possible solution:
MATCH (s:Entity)-[]-(dest) WHERE s._id = 'xxx'
WITH collect(dest)[..100] as childrenSource
LIMIT 100
MATCH (childrenSource)-[]-(childDestination)
RETURN childrenSource as expandNode, collect(childDestination)[..100] as childrenIds
But i dont thinks this is a performant solution. Because it takes quite a lot of time
Exact Problem description: If i have 1 node with 1000 children and each child has another 1000 children i want to execute a query which returns 100 children with 100 child ids
-------------------------------------------------
| node 1 | child id 1_1,.... child id 1_100 |
| node 2 | child id 2_1,.... child id 2_100 |
| ... | ... |
| node 100 | child id 100_1,.. child id 100_100 |
-------------------------------------------------
Other solution: i do a simple expand for the node. and than i call an expand on each child node. But doing 101 queries instead of 1 query sounds not too performant either.