I am trying to insert array of objects as property to node. I tried
MERGE (ss:Label1 {sId: 12345})
ON MATCH SET ss.id = 14770746012, ss.setC = 1,ss.nl = [{id: 24, status: 0}]
ON CREATE SET ss.id = 14770746012, ss.setC = 1,ss.nl = [{id: 24, status: 0}]
If run I am getting follwing error::
Property values can only be of primitive types or arrays thereof
What to even I tried with nested array, that gave me same error as above.
I studied in Neo4j documentation that Neo4j can't support 'Nesting of property values'
How to achieve my requirement?
As Neo4j not support hierarchical properties, one of the ways to solve this problem - to create additional nodes:
MERGE (ss:Label1 {sId: 12345, id: 14770746012, setC: 1 })
MERGE (nl:Props:nlProp {id: 24, status: 0})
MERGE (ss)-[:hasProps]->(nl)
As mentioned by stdob--, you can create additional nodes if your need to use those properties in queries (for filtering, aggregation, etc.).
If however, you just want to write and read the data but not act on it in queries, you can serialize it, for example as JSON:
MERGE (ss:Label1 {sId: 12345})
ON MATCH SET ss.id = 14770746012, ss.setC = 1,ss.nl = ["{\"id\": 24, \"status\": 0}"]
ON CREATE SET ss.id = 14770746012, ss.setC = 1,ss.nl = ["{\"id\": 24, \"status\": 0}"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With