cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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.

1 ACCEPTED SOLUTION

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

View solution in original post

4 REPLIES 4

Seems like I just found it, adding it here for reference: Generating Graphs - APOC 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

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:
https://neo4j.com/docs/cypher-refcard/current/