Adding a prefix or suffix to existing relation property

Is there a way to update the existing relationship property with a prefix without losing the existing property value in there.
in the following example, I have connected multiple nodes by level 1, 2, 3. I would like to update the property level with prefix "Journey" for the following graph using cypher.
I have tried using "set" but its overriding the existing level value.


Welcome to the community.
Is that you are trying to update the relationship property name from level to Journey Level?
Please let me know the query you are trying to run which is not giving you the expected result and what is your expected result.



if you want to change the value of the property you can do it by concatenating your prefix with the existing value, e.g.

MATCH (a)-[r]->(b)
SET r.level= "Journey " + r.level

This will change the values from "1", "2", "3",... to "Journey 1", "Journey 2", "Journey 3"...

Or if you want to change the name of the property you can do

MATCH (a)-[r]->(b)
SET r.JourneyLevel = r.level
REMOVE r.level

This will create a new property with the old property's value and remove the old property.


1 Like

Thank you.
i was using
MATCH (a)-[r]->(b)
SET r.level= "Journey"
but the following query provided by elen worked for me.

Thank you. the first one worked.