How to rename (remove old and add new) property for all nodes in Neo4j database?

I have a db of almost 50000 nodes and almost 300k properties connected to those nodes.

I was able to rename node labels like below:

// Rename x Node labels
MATCH (n:OLD_LABEL {id:14})
REMOVE n:OLD_LABEL
SET n:NEW_LABEL

MATCH (n:CLASSIFICATIONSTANDARD)
REMOVE n:CLASSIFICATIONSTANDARD
SET n:Eclass;

But when I try to change the name of a property for all nodes the neo4j crashed. Can I run this script in a batch of 1000 each?

CALL apoc.periodic.iterate https://neo4j.com/labs/apoc/4.4/overview/apoc.periodic/apoc.periodic.iterate/

Looks like a good options, but it only allows three argument so I don¨'t know how to run all this code:

match (t:Eclass) 
SET t.irdicc = t.irdiCc 
REMOVE t.irdiCc
return true;

match (t:Eclass) return t.irdicc;

Hello @kasipasi :grinning:

You should always do like this when you need to set thousands of nodes or relations:

CALL apoc.periodic.iterate(
    "MATCH (t:Eclass) RETURN t",
    "SET t.irdicc = t.irdiCc REMOVE t.irdiCc",
    {batchSize: 1000}
)
YIELD batch, operations;

Regards,
Cobra

@Cobra

Thank you for your reply!

This function did drop the label irdiCc, but did not create t.irdicc and stored the value.

When I run:

match (t:Eclass) return t.irdicc;

I get NULL on all those properties.

kasipasi_0-1664394482746.png

That's weird, can you reload your nodes with the old property and try this query?

CALL apoc.periodic.iterate(
    "MATCH (t:Eclass) RETURN t",
    "SET t.irdicc = t.irdiCc, t.irdiCc = null",
    {batchSize: 1000}
)
YIELD batch, operations;