Creating nodes and relationships from a map with 500K items

Hello. I am trying to learn how to load a json file and create the nodes and relationships. My json file has ~500K messages with 5 lists each: frame, ip, upd, eth, and data. I have learned how to read in the json file and then create one (1) message in the DBMS with all the appropriate nodes and relationships (thanks to those who helped school me). Not I need to figure out how to go through the map and to that for all 500k messages. I tried a FOREACH, but it only creates the first message an nothing else. I don't know if I am using the FOREACH incorrectly or if I should be using something else. Here is the pertinent parts:

CALL apoc.load.json("file:///FileExample.json") YIELD value
UNWIND value._source.layers as bigData

FOREACH (data in bigData |
a bunch of merge and sets

How can I cycle through the 500K messages to get them in the DBMS?

Check these two links:

Yes, I have downloaded and installed JSON.

Yes, I do have to be careful about that. But the main problem is not being able to go through the data and pull the next message. My code goes through one, creates the nodes and relationships and that's it. How do I get it to continue through the list creating all 500K nodes?

I found the solution and I am posting it here to help others and close this out. I found an example in the book "Hands-On Graph Analytics with Neo4j" (I have no affiliation). Here is what worked to go through a nested JSON file and add it to the DBMS. I do have to add the other parts, but that is just like the example.

//Load JSON file
CALL apoc.load.json("file:///FileExample.json") YIELD value AS data
//Create top level object
CREATE (l:Layers {name: "FileExample"})
//Create ETH
CREATE (e:ETH {addr_oui:,
//Create UDP
CREATE (u:UDP {srcport: data._source.layers.udp.udp.srcport})
//Create Data
CREATE (d:Data {len:})
//Create Frame
CREATE (f:Frame {number: data._source.layers.frame.frame.number})

1 Like

Thanks for sharing this.