Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-16-2022 07:02 AM
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
Solved! Go to Solution.
06-16-2022 08:57 AM - edited 06-16-2022 08:59 AM
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`
06-16-2022 08:57 AM - edited 06-16-2022 08:59 AM
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`
06-27-2022 05:17 AM
Thanks for the explanation! It is clear now 🙂
All the sessions of the conference are now available online