A very newbie question: how does "LIMIT" in Cypher limit results?

Hello, everyone,

I am wondering of the "limit" clause in cypher and I searched its documentation but have not found an explanation yet. How does the "Limit" limit nodes, based on what criteria?

e.g. if I run

match (n) return n limit 10

then 10 nodes will be returned, but why these 10 not other 10? Are they selected based on index or what? I first thought they were randomly picked, but if I rerun the code, the result is the same. Therefore, I this the clause must select the nodes based on certain criteria.

I would appreciate for any explanation and hint. Thanks and Best

@yuxin

The criteria with which neo4j obtains the result are the internal ids of the nodes and relationships.

In fact, if you create a new database with for example 100 nodes and 50 relationships,
executing a "match (n) return id(n) limit 5" or a "match ()-[r]->() return id(r) limit 5",

the results will always be `0,1,2,3,4`

Thanks for the explanation! It is clear now :slightly_smiling_face: