Rename property name

(Jeffreylm) #1

Dear Everyone,

I am a newbie (February 2019) transferring my Amazon product database from Filemaker to Neo4J. On the Amazon platform they use an acronym ASIN (Amazon Standard Identification Number).
As a newbie I named one of my properties in the Neo4j database ASIN, only to now find out it is a function in Neo4j (also was the reason I couldn't match based on ASIN, took a few days to figure that one out.)

How do I rename all the property labels on all the product nodes? I couldn't find anything in the documentation.

Thank you in advance.

Kind regards,
Jeffrey

0 Likes

(M. David Allen) #2

Use SET/REMOVE, like this:

create (:TestRecord { oldName: 'Hello' });

match (t:TestRecord) 
SET t.newName = t.oldName 
REMOVE t.oldName 
return true;

match (t:TestRecord) return t.newName;
1 Like

(Jeffreylm) #3

Hello David,

Thank you for the explanation.

Am I to understand that the SET will automatically make the property when used in the way you posted it?
And what was the reasoning behind using the "RETURN true;"

Jeffrey

0 Likes

(M. David Allen) #4

Yes, SET will create a new property on the node. So we're really not "renaming" a property, we're creating a new one and deleting the old one (same thing).

There's no reasoning behind "RETURN true". You could omit this and there'd be no harm. I was just thinking return true to signal to the caller that the query had executed.

1 Like

(Jeffreylm) #5

Hello David,

Could you elaborate a bit on the concept of "signal the caller that the query had executed"

Thanks in advance,
Jeffrey

0 Likes