apoc.refactor.cloneNodesProcedure
| Syntax | 
 | ||
| Description | Clones the given  | ||
| Input arguments | Name | Type | Description | 
| 
 | 
 | The nodes to be cloned. | |
| 
 | 
 | Whether or not the connected relationships should also be cloned. The default is:  | |
| 
 | 
 | Whether or not to skip the node properties when cloning. The default is:  | |
| Return arguments | Name | Type | Description | 
| 
 | 
 | The internal id of the original entity. | |
| 
 | 
 | The copied entity. | |
| 
 | 
 | Any error that occurred during the copy process. | |
Refactoring nodes using Cypher
Node labels can be referenced dynamically in Cypher without using APOC.
CREATE (n1:$(label))
MERGE (n1:$(label))
MATCH (n1:$(label))The dynamically calculated label must evaluate to a STRING or LIST<STRING>.
For more information, see the Cypher Manual → CREATE,
MERGE, MATCH.
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (mark:Person {name: "Mark", city: "London"})
CREATE (jennifer:Person {name: "Jennifer", city: "St Louis"})The following examples create copies of all Person nodes using both APOC and Cypher:
MATCH (p:Person)
WITH collect(p) AS people
CALL apoc.refactor.cloneNodes(people)
YIELD input
MATCH (p:Person)
RETURN DISTINCT pMATCH (p:Person)
CREATE (n:$(labels(p)))
SET n = properties(p)
WITH *
MATCH (p:Person)
RETURN DISTINCT p| p | 
|---|
| (:Person {name: "Mark", city: "London"}) | 
| (:Person {name: "Jennifer", city: "St Louis"}) | 
| (:Person {name: "Mark", city: "London"}) | 
| (:Person {name: "Jennifer", city: "St Louis"}) |