apoc.refactor.rename.label
Procedure APOC Core
apoc.refactor.rename.label(oldLabel, newLabel, [nodes]) | rename a label from 'oldLabel' to 'newLabel' for all nodes. If 'nodes' is provided renaming is applied to this set only
Signature
apoc.refactor.rename.label(oldLabel :: STRING?, newLabel :: STRING?, nodes = [] :: LIST? OF NODE?) :: (batches :: INTEGER?, total :: INTEGER?, timeTaken :: INTEGER?, committedOperations :: INTEGER?, failedOperations :: INTEGER?, failedBatches :: INTEGER?, retries :: INTEGER?, errorMessages :: MAP?, batch :: MAP?, operations :: MAP?, constraints :: LIST? OF STRING?, indexes :: LIST? OF STRING?)
Input parameters
Name | Type | Default |
---|---|---|
oldLabel |
STRING? |
null |
newLabel |
STRING? |
null |
nodes |
LIST? OF NODE? |
[] |
Output parameters
Name | Type |
---|---|
batches |
INTEGER? |
total |
INTEGER? |
timeTaken |
INTEGER? |
committedOperations |
INTEGER? |
failedOperations |
INTEGER? |
failedBatches |
INTEGER? |
retries |
INTEGER? |
errorMessages |
MAP? |
batch |
MAP? |
operations |
MAP? |
constraints |
LIST? OF STRING? |
indexes |
LIST? OF STRING? |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (mark:Engineer {name: "Mark", city: "London"})
CREATE (jennifer:Engineer {name: "Jennifer", city: "St Louis"})
CREATE (michael:Engineer {name: "Michael", city: "Dresden"})
CREATE (jim:Engineer {name: "Jim", city: "London"})
CREATE (alistair:Engineer {name: "Alistair", city: "London"})
MERGE (jim)-[:COLLEAGUES {since: date("2006-05-01")}]->(alistair)
MERGE (mark)-[:COLLEAGUES {since: date("2018-02-01")}]->(jennifer)
MERGE (mark)-[:COLLEAGUES {since: date("2013-05-01")}]->(michael);
The following changes the relationship type between Jim and Alistair from COLLEAGUES
to FROLLEAGUES
:
MATCH (:Engineer {name: "Jim"})-[rel]->(:Engineer {name: "Alistair"})
WITH collect(rel) AS rels
CALL apoc.refactor.rename.type("COLLEAGUES", "FROLLEAGUES", rels)
YIELD batches, total, timeTaken, committedOperations
RETURN batches, total, timeTaken, committedOperations;
batches | total | timeTaken | committedOperations |
---|---|---|---|
1 |
1 |
0 |
1 |
After this query has run, we’ll have the following graph: