HOW TO, Create node if not exist, update if exist with new supplied data / merging the current with new

How can I accomplish the following.

was looking at using

CREATE (ah:AccountHolder {
  accountEntityId: "CABLZAJJ-1366999182",
  accountId: "1366999182",
  tenantId: "CABLZAJJ",
  accountAgentId: "CABLZAJJ",
  bicfi: "CABLZAJJ",
  fullName: "TINY"
}) ON DUPLICATE KEY IGNORE;

and created a unique constraint on AccountHolder: accountEntityId
but it seems this on DUPLICATE is incorrect/wrong, so thinking how better to do...

So was thinking of using a Merge statement.

If the node does not exist, create it.
if it exists with say 4 fields, and I got 6, 3 new, 3 old, update the current 3 and add the new 3 fields.

aka Merging old and new... worried, without loosing old.
where the same field name is specified, the old value is updated with new value.

MERGE (ah:AccountHolder {accountEntityId: event.accountEntityId}) 
SET ah.accountId=event.accountId, 
	ah.tenantId=event.tenantId,
	ah.accountAgentId=event.accountAgentId,
	ah.optional=event.optional;

worried here... ah.optional will be reset to whatever event.optional is, wiping out the old contents, issue is optional is a dynamic list...
I need to some how have some elasticity in which fields are being ingested (this will form part of a Kafka Connect sink job.)

G

On your other thread I gave you an example of merge to achieve what you want.

You could even choose to move "current properties" to "previous properties" if you wanted to.

and i did not understand it...

I ended using the following

"MERGE (a:AccountHolder {accountEntityId: event.accountEntityId})
ON CREATE SET 
  a.accountId = event.accountId,
  a.tenantId = event.tenantId,
  a.accountAgentId = event.accountAgentId,
  a.bicfi = event.bicfi,
  a.fullName = event.fullName
ON MATCH SET 
  a.accountId = event.accountId,
  a.tenantId = event.tenantId,
  a.accountAgentId = event.accountAgentId,
  a.bicfi = event.bicfi,
  a.fullName = event.fullName"

Next up is to create the links between banks uploaded from csv file and these accounts. bank:tenantId =>accountHolder.tenandId