Momoe
Momoe

Reputation: 21

how to replace a property in a neo4j relationship

I'm new to NEO4j and Keetle etl.

Now I am trying to replace property value "costPerTon" in a relationship :COMPANY_COST_FOR_PRODUCT_{period}_{company}

I have the value calculated in Kettle and try to import them using Neo4j Cypher, but I don't know how to write this cypher...

should I use Merge or Set?

Upvotes: 0

Views: 71

Answers (1)

Graphileon
Graphileon

Reputation: 5385

MERGE finds you the relationship (if it exists) , SET only sets a property on a relationship once you have found /created it.

For relationships, make are you first find the start and end nodes, once you have them

assuming you have found the (start) and (end) nodes

you can do

// Find the rel, or create it if it does not yet exist
MERGE (start)-[r:MyRELTYPE]->(end)
// Set the property value
SET r.myProperty =  myPropertyValue

Upvotes: 1

Related Questions