Reputation: 11
I have a node and I want to add one property property_x
whose value I want to be {"year1":value, "year2":value}
. Making more than one node for each year is not needed as I need these values in my processing together.
Upvotes: 0
Views: 874
Reputation: 121987
Neo4j only supports certain kinds of properties (docs):
...there are restrictions as to what types of values can be used as property values. Allowed value types are as follows:
Numbers: Both integer values, with capacity as Java’s
Long
type, and floating points, with capacity as Java’sDouble
.Booleans.
Strings.
Arrays of the basic types above.
You therefore cannot set a dictionary as a property. You could try using json.dumps
to convert the dictionary to a JSON string and storing the string. However, this will mean that you cannot easily use the content of the object when writing queries, and will need to json.loads
the data back when you retrieve the node.
Alternatively, you could make the object a separate node with the properties year1
, year2
, etc., and link it to the first node with a relationship.
Upvotes: 3