Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-22-2020 01:11 AM
Hi All,
I'm using apoc.merge.node to load a CSV one of my fields is an array.
How do I add elements to an array property with APOC?
Somehow I need to reference what has already been entered into the array.
In the following Cypher I've labeled what I'm missing with "Elements_Already_Here" but I'm not sure how to do this? Maybe I'm on the wrong path and need to do it another way.
LOAD CSV WITH HEADERS FROM 'file:/hrsm-upload-sample.csv' AS line
CALL apoc.merge.node(
["BusinessRole"],{name:line.FullTitle},
{PositionNumber:[line.PositionNumber]},
{PositionNumber:[Elements_Already_Here] + [line.PositionNumber]}
) YIELD node
RETURN node
Thanks in advance.
Lance.
05-22-2020 04:58 AM
I'd use a normal merge
here.
LOAD CSV WITH HEADERS FROM 'file:/hrsm-upload-sample.csv' AS line
MERGE (b:BusinessRole{name:line.FullTitle})
ON CREATE SET b.PositionNumber = [line.PositionNumber]
ON MATCH SET b.PositionNumber += [line.PositionNumber]
RETURN b
05-22-2020 05:45 AM
Thanks I tried it and got a syntax error with =+
Invalid input '+': expected whitespace, comment, '(', '.' or '=' (line 4, column 31 (offset: 195))
So I changed:
ON MATCH SET b.PositionNumber += [line.PositionNumber]
to:
ON MATCH SET b.PositionNumber = b.PositionNumber + [line.PositionNumber]
and it worked.
Thanks again.
All the sessions of the conference are now available online