0

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.

AlBlue
  • 23,254
  • 14
  • 71
  • 91
  • Tried to edit but the question is very vague and needs more details if you hope it to be answered. – AlBlue Jun 25 '16 at 12:34

1 Answers1

3

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’s Double.

  • 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.

Community
  • 1
  • 1
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437