apoc.refactor.rename.typeProperty

Details

Syntax

apoc.refactor.rename.typeProperty(oldName, newName [, rels, config ]) :: (batches, total, timeTaken, committedOperations, failedOperations, failedBatches, retries, errorMessages, batch, operations, constraints, indexes)

Description

Renames the given property from oldName to newName for all RELATIONSHIP values. If a LIST<RELATIONSHIP> is provided, the renaming is applied to the RELATIONSHIP values within this LIST<RELATIONSHIP> only.

Input arguments

Name

Type

Description

oldName

STRING

The property to rename.

newName

STRING

The new name to give the property.

rels

LIST<RELATIONSHIP>

The relationships to apply the new name to. If this list is empty, all relationships with the old properties name will be renamed. The default is: [].

config

MAP

{ batchSize = 100000 :: INTEGER, concurrency :: INTEGER, retries = 0 :: INTEGER, parallel = true :: BOOLEAN, batchMode = "BATCH" :: STRING }. The default is: {}.

Return arguments

Name

Type

Description

batches

INTEGER

The number of batches the operation was run in.

total

INTEGER

The total number of renamings performed.

timeTaken

INTEGER

The time taken to complete the operation.

committedOperations

INTEGER

The total number of committed operations.

failedOperations

INTEGER

The total number of failed operations.

failedBatches

INTEGER

The total number of failed batches.

retries

INTEGER

The total number of retries.

errorMessages

MAP

The collected error messages.

batch

MAP

{ total :: INTEGER, failed :: INTEGER, committed :: INTEGER, errors :: MAP }

operations

MAP

{ total :: INTEGER, failed :: INTEGER, committed :: INTEGER, errors :: MAP }

constraints

LIST<STRING>

Constraints associated with the given label or type.

indexes

LIST<STRING>

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 relationship property since to from for all relationships:

MATCH ()-[rel]->()
WITH collect(rel) AS rels
CALL apoc.refactor.rename.typeProperty("since", "from", rels)
YIELD batches, total, timeTaken, committedOperations
RETURN batches, total, timeTaken, committedOperations;
Results
batches total timeTaken committedOperations

1

3

0

3

The following query returns all the paths in our graph after this refactoring has been done:

MATCH path = ()-[]->()
RETURN path
Results
path

[{"name":"Mark","location":"London"},{"from":"2018-02-01"},{"name":"Jennifer","location":"St Louis"}]

[{"name":"Mark","location":"London"},{"from":"2013-05-01"},{"name":"Michael","location":"Dresden"}]

[{"name":"Jim","city":"London"},{"from":"2006-05-01"},{"name":"Alistair","city":"London"}]