Neo4j: Cypher - Property values can only be of primitive types or arrays thereof.
I ran into an interesting Cypher error message earlier this week while trying to create an array property on a node which I thought I’d share.
This was the Cypher query I wrote:
CREATE (:Person {id: [1, "mark", 2.0]})
which results in this error:
Neo.ClientError.Statement.TypeError
Property values can only be of primitive types or arrays thereof.
We actually are storing an array of primitives but we have a mix of different types which isn’t allowed. Let’s try coercing all the values to strings:
CREATE (:Person {id: [value in [1, "mark", 2.0] | toString(value)]})
Added 1 label, created 1 node, set 1 property, completed after 4 ms.
Success!
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.