apoc.create.removeProperties

Procedure

apoc.create.removeProperties(nodes ANY, labelsLIST<STRING>) - removes the given properties from the given NODE values.

Signature

apoc.create.removeProperties(nodes :: ANY, keys :: LIST<STRING>) :: (node :: NODE)

Input parameters

Name Type Default Description

nodes

ANY

null

nodes can be of type STRING (elementId()), INTEGER (id()), NODE or LIST<STRING | INTEGER | NODE>.

keys

LIST<STRING>

null

The property keys to remove from the given NODE values.

Output parameters

Name Type

node

NODE

Usage Examples

Cypher supports deleting of node properties as long as the property names are hard coded. If the property names are dynamically specified we can use this procedure instead.

The examples in this section are based on the following sample graph:

CREATE (jennifer:Person {name: "Jennifer", community: 1, partition: 4})
CREATE (karin:Person {name: "Karin", community: 4, partition: 2})
CREATE (elaine:Person {name: "Elaine", community: 3, partition: 3})
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-06-01")}]-(karin)
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-05-04")}]-(elaine);

We can delete all properties from relationships, by running the following query:

CALL db.propertyKeys()
YIELD propertyKey WHERE propertyKey <> "name"
WITH collect(propertyKey) AS propertyKeys
MATCH (p:Person)
WITH collect(p) AS nodes, propertyKeys
CALL apoc.create.removeProperties(nodes, propertyKeys)
YIELD node
RETURN node;
Table 1. Results
node

(:Person {name: "Jennifer"})

(:Person {name: "Karin"})

(:Person {name: "Elaine"})