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.

Problem using UNWIND and SET for batch operations in Java driver

Using Enterprise version 4.2.5, I am trying to do batch operations (for example creating Nodes) in a performant way. I understand that passing in lists of parameters and using UNWIND is a good practice, so I attempted the following:

UNWIND $batch as row CREATE (n:AtkeWordl) SET n += row

Where the $batch variable contains a list of map structures like this:

"[{propertyA: "Value1", propertyB: "Value2"}, {propertyA: "Value3", propertyB: "Value4"}]

However, from my Java client I go the following exception:

org.neo4j.driver.exceptions.ClientException: Type mismatch: expected Map, Node or Relationship but was String (line 1, column 51 (offset: 50))
"UNWIND $batch as row CREATE (n:AtkeWord) SET n += row"
^

The Cypher docs indicate that you should be able to set Node properties using a Map and the Set = or SET += operators. Is this a bug in the Java driver? Or any suggestions to fix this, or alternatives for performant (programmatic) batch operations from Java?

2 REPLIES 2

you need to drop the +

with [{propertyA: "Value1", propertyB: "Value2"}, {propertyA: "Value3", propertyB: "Value4"}] as input
UNWIND input as row CREATE (n:AtkeWord) SET n = row

Thank you - I realized I was passing the data in to the Java driver as a JSON string, so I just tried passing it into the call as a List of Maps instead, which worked perfectly (even with the +=).