apoc.refactor.rename.label
Procedure
apoc.refactor.rename.label(oldLabel STRING, newLabel STRING, nodes LIST<NODE>)
- renames the given label from oldLabel
to newLabel
for all NODE
values.
If a LIST<NODE>
is provided, the renaming is applied to the NODE
values within this LIST<NODE>
only.
Signature
apoc.refactor.rename.label(oldLabel :: STRING, newLabel :: STRING, nodes = [] :: LIST<NODE>) :: (batches :: INTEGER, total :: INTEGER, timeTaken :: INTEGER, committedOperations :: INTEGER, failedOperations :: INTEGER, failedBatches :: INTEGER, retries :: INTEGER, errorMessages :: MAP, batch :: MAP, operations :: MAP, constraints :: LIST<STRING>, indexes :: LIST<STRING>)
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<STRING> |
indexes |
LIST<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 label on Mark, Jennifer, and Michael from Engineer
to DevRel
:
MATCH (person:Engineer)
WHERE person.name IN ["Mark", "Jennifer", "Michael"]
WITH collect(person) AS people
CALL apoc.refactor.rename.label("Engineer", "DevRel", people)
YIELD batches, total, timeTaken, committedOperations
RETURN batches, total, timeTaken, committedOperations;
batches | total | timeTaken | committedOperations |
---|---|---|---|
1 |
3 |
0 |
3 |
After this query has run, we’ll have the following graph: