Reputation: 809
I'm using neo4j 2.01
Could you please tell me how to make this map literals work?
neo4j-sh (?)$ MERGE (n:person {name:'Alice', age:38, address:{city:'London', residential:true}}) RETURN n;
MatchError: Map(city -> London, residential -> true) (of class scala.collection.immutable.Map$Map2)
Thank you in advance for your kind help. Marco
Upvotes: 1
Views: 75
Reputation: 39915
Map literals are only allowed in the RETURN
clause. Neo4j properties on nodes are either primitives, Strings or arrays of them. If you want to store a more complex value with a node, decompose the complex value into a set of nodes and relationships and attach it to your entity node with a relationship:
MERGE (n:person {name:'Alice', age:38})-[:LIVES_IN]->(a:address {city:'London', residential:true}}) RETURN n,a;
Even the residential
flag is implicitly encoded into the relationship as LIVES_IN
, so you might omit it and rely on verbose relationship types.
To use map literals in RETURN
:
match (n:person)-[:LIVES_IN]->(a:address) return {name:n.name, age:n.age, address:a}
Upvotes: 1