Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-02-2022 09:08 AM
Is there some simple way to generate random data when playing with Neo4j browser, please? In other databases I can do something like this:
FOR i IN 1..1000
INSERT {
name: CONCAT("test", i),
value: 100 + FLOOR(RAND() * (150 - 100 + 1))
} IN myCollection
to generate 1000 nodes. Is there something similar in Cypher, please? Thank you.
Solved! Go to Solution.
02-02-2022 06:23 PM
You can do something as follows directly in cypher.
with range(1,5) as indexes
unwind indexes as index
create(n:LABEL {randomValue: rand()})
return n
02-02-2022 11:21 AM
Seems like I just found it, adding it here for reference: Generating Graphs - APOC Documentation
02-02-2022 06:23 PM
You can do something as follows directly in cypher.
with range(1,5) as indexes
unwind indexes as index
create(n:LABEL {randomValue: rand()})
return n
02-03-2022 03:32 AM
excellent, thank you!
02-03-2022 04:32 AM
Your welcome. Other math operations you can use can be found here, such as ceil and floor:
And the reference card is great:
https://neo4j.com/docs/cypher-refcard/current/
All the sessions of the conference are now available online