Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 1: replicate users.

Parsing a complex JSON with lots of UNWIND and MERGE, is there a limit to the number of variables we can pass in a WITH clause?


Dear all, I am a new user on Neo4j and I am facing a problem to parse a complex nested JSON.
The json is a so-called FHIR bundle (healthcare standard with HL7 ontology), it is a complex deeply nested json with arrays in it.
The core of the json is an 'entry' array where there are different resource jsons (patient, practitioner, encounter etc.). Every resource json has it own structure and these resources can be present several times in the array but with different parameters.
My idea is to unwind the list and filter the resource type to build the nodes in sequence. If I have let's say 15 different resources, I am filtering with the [x IN WHERE] AS the 'entry' variable. I will do that in sequence, passing variables with WITH statement in between UNWIND, MERGE or MATCH clauses. According to that my WITH line is getting longer and longer as I need to pass node variables to be able to create the edges. I am using MERGE most of the time as I don't want to create doublons when not required. Everything is working fine until it seems that the UNWIND with filtering seems not to work anymore (for the last two nested jsons, which is frustrting). UNWIND and filter these last two jsons independently works, so the problem is not in the json. I wanted to know if there is memory cache issue due to the number of variables which are passed through the WITH clause? Or is there a limit for the number of variables that can be passed with a WITH?


Graph Buddy

Goodmorning, maybe you can make use of the Neo4j Apoc plugin:

Yours kindly


I have a similar problem, when I'm parsing github api data.


The best solution to parse the complex json data onto neo4j platform is to flatten the data and use apoc to make labels, nodes and relationships and unflatten while retrieving it from neo4j.