Neo4j Cypher Pattern comprehension and SKIP/LIMIT

Viewed 17

I intensively use the Neo4j Cypher Pattern comprehension, for example:

[(jobable)-[vg1:HAS_VOTE_ON]->(c1:Criterion)<-[:HAS_VOTE_ON]-(childD) | {criterion: c1, relationship: vg1} ] AS jobableWeightedCriterion

and realized that the returned data from the Pattern comprehension query could be quite big. Is it possible to control the amount of the data returned from the Pattern comprehension part of the query.. for example something like SKIP/LIMIT ?

1 Answers

Yes you can, pattern comprehension returns a list, so you can apply a skip and limit, to the list like this:

[(jobable)-[vg1:HAS_VOTE_ON]->(c1:Criterion)<-[:HAS_VOTE_ON]-(childD) | 
 {criterion: c1, relationship: vg1} ][$skip..$skip + $limit] AS jobableWeightedCriterion

For, skip value 5 and limit 5, it will look like this:

[(jobable)-[vg1:HAS_VOTE_ON]->(c1:Criterion)<-[:HAS_VOTE_ON]-(childD) | 
 {criterion: c1, relationship: vg1} ][5..10] AS jobableWeightedCriterion
Related