apoc.create.removeProperties

Procedure APOC Core

apoc.create.removeProperties( [node,id,ids,nodes], [keys]) - removes the given properties from the nodes(s)

Signature

apoc.create.removeProperties(nodes :: ANY?, keys :: LIST? OF STRING?) :: (node :: NODE?)

Input parameters

Name Type Default

nodes

ANY?

null

keys

LIST? OF STRING?

null

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"})