Nested Maps and Collections in Neo4j 2
I understand that node and relationship properties are limited to primitive types or arrays of primitive types. The "Maps" section of the Neo4j 2.1 Reference Card mentions that:
{name:'Alice', age:38, address:{city:'London', residential:true}}
Literal maps are declared in curly braces much like property maps. Nested maps and collections are supported.
Of course something like:
CREATE (alice {name:'Alice', age:38, address:{city:'London', residential:true}})
throws an exception:
Error: Property values can only be of primitive types or arrays thereof Neo.ClientError.Statement.InvalidType
In what context does Neo4j support nested maps and collections?
(Edited)
The reference card is a bit too subtle. The most important word is "literal". In other words, you can only use arbitrarily nested maps and arrays in literals, but you cannot store such things in a node or relationship.
For example, this works:
WITH {name:'Alice', age:38, address:[{city:'London', residential:true}, {city: 'Paris', residential: false} ]} AS x
RETURN x;
But this fails:
CREATE (x {name:'Alice', age:38, address:[{city:'London', residential:true}, {city: 'Paris', residential: false} ]})
RETURN x;