Sometimes a customer wants to utilize SKIP and LIMIT in CYPHER to have the results come in groups, i.e., pagination. An example would be:
MATCH (v:Value)
ORDER BY v.order_date
RETURN v
SKIP 0
LIMIT 5
MATCH (v:Value)
ORDER BY v.order_date
RETURN v
SKIP 5
LIMIT 5
There is one critical aspect for this to work properly, as the documentation states:
By using SKIP
, the result set will get trimmed from the top. Please note that no guarantees are made on the order of the result unless the query specifies the ORDER BY
clause.
Even further, for the ORDER BY
clause it is critical there are no duplicate values. Because when you have duplicate values for ORDER BY
column, that sorted result is not guaranteed to output them in any particular order. This can cause the pagination to "break" repeating some entries and basically just not sorting them as expected.
- LIMIT Documentation: https://neo4j.com/docs/cypher-manual/current/clauses/limit/
- SKIP Documentation: https://neo4j.com/docs/cypher-manual/current/clauses/skip/
Comments
0 comments
Please sign in to leave a comment.