apoc.refactor.rename.nodeProperty
Syntax |
|
||
Description |
Renames the given property from |
||
Input arguments |
Name |
Type |
Description |
|
|
The property to rename. |
|
|
|
The new name to give the property. |
|
|
|
The nodes to apply the new name to. If this list is empty, all nodes with the old property name will be renamed. The default is: |
|
|
|
|
|
Return arguments |
Name |
Type |
Description |
|
|
The number of batches the operation was run in. |
|
|
|
The total number of renamings performed. |
|
|
|
The time taken to complete the operation. |
|
|
|
The total number of committed operations. |
|
|
|
The total number of failed operations. |
|
|
|
The total number of failed batches. |
|
|
|
The total number of retries. |
|
|
|
The collected error messages. |
|
|
|
|
|
|
|
|
|
|
|
Constraints associated with the given label or type. |
|
|
|
Indexes associated with the given label or type. |
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 query changes the node property city
to location
for all nodes with the DevRel
label:
MATCH (person:DevRel)
WITH collect(person) AS people
CALL apoc.refactor.rename.nodeProperty("city", "location", people)
YIELD batches, total, timeTaken, committedOperations
RETURN batches, total, timeTaken, committedOperations;
batches | total | timeTaken | committedOperations |
---|---|---|---|
1 |
3 |
0 |
3 |
The following query returns all the nodes in our graph after this refactoring has been done:
MATCH (n)
RETURN (n)
n |
---|
(:DevRel {name: "Jennifer", location: "St Louis"}) |
(:DevRel {name: "Michael", location: "Dresden"}) |
(:Engineer {city: "London", name: "Jim"}) |
(:DevRel {name: "Mark", location: "London"}) |
(:Engineer {city: "London", name: "Alistair"}) |