cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Inserting a Python Dictionary Inside a Node

I'm trying to put a Python dictionary inside of nodes, because I recieve data as a dictionary in Python and need to save it in Neo4j.

My query looks like this: "create (a {name:"node", text: "", values: {color: "red", size: "7 m"}}) "
and it gives me this error: "Neo.ClientError.Statement.TypeError
Property values can only be of primitive types or arrays thereof. Encountered: Map{color -> String("red"), size -> String("7 m")}."

I don't understand this because in the manual section Neo4j Cypher Manual / Syntax / Maps dictionaries get referred to as maps and are used just like i do in the above query.

How to solve this error?

1 ACCEPTED SOLUTION

Hello @m.h98

You cannot store a map as a property but you can use a map to set several properties. I don't know if it's clear? In your case, you are doing both so you can solve your issue by removing the depth from your map:

CREATE (a {name:"node", text: "", color: "red", size: "7 m"})

The only composite object that you can store is a list of homogeneous type such as a list of integers.

Regards,
Cobra

View solution in original post

1 REPLY 1

Hello @m.h98

You cannot store a map as a property but you can use a map to set several properties. I don't know if it's clear? In your case, you are doing both so you can solve your issue by removing the depth from your map:

CREATE (a {name:"node", text: "", color: "red", size: "7 m"})

The only composite object that you can store is a list of homogeneous type such as a list of integers.

Regards,
Cobra

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online