Generate test data

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.

Seems like I just found it, adding it here for reference: Generating Graphs - APOC Extended Documentation

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

1 Like

excellent, thank you!

Your welcome. Other math operations you can use can be found here, such as ceil and floor:

And the reference card is great:

1 Like