apoc.graph.filterProperties
Procedure Apoc Extended
CALL apoc.graph.filterProperties(anyEntityObject, nodePropertiesToRemove, relPropertiesToRemove) YIELD nodes, relationships Returns a set of virtual nodes and relationships without the properties defined in nodePropertiesToRemove and relPropertiesToRemove
Signature
apoc.graph.filterProperties(value :: ANY?, nodePropertiesToRemove = {} :: MAP? , relPropertiesToRemove = {} :: MAP?) :: ANY?
Output parameters
Name | Type |
---|---|
nodes |
LIST OF NODE? |
relationships |
LIST OF RELATIONSHIP? |
The nodePropertiesToRemove
and relPropertiesToRemove
parameter are maps
with key the label/relationship type and value the list of properties to remove from the virtual entities.
The key can also be _all
, for both of them, which means that the properties of each label/rel-type are filtered.
Usage examples
Given the following dataset:
CREATE (:Person {name: "foo", plotEmbedding: "11"})-[:REL {idRel: 1, posterEmbedding: "33"}]->(:Movie {name: "bar", plotEmbedding: "22"}),
(:Person {name: "baz", plotEmbedding: "33"})-[:REL {idRel: 1, posterEmbedding: "66"}]->(:Movie {name: "ajeje", plotEmbedding: "44"})
we can execute:
MATCH path=(:Person)-[:REL]->(:Movie)
WITH collect(path) AS paths
CALL apoc.graph.filterProperties(paths, {Movie: ['posterEmbedding'], Person: ['posterEmbedding', 'plotEmbedding', 'plot', 'bio']})
YIELD nodes, relationships
RETURN nodes, relationships
nodes | relationships |
---|---|
[(:Person {name: "1"}), (:Movie {name: "bar"}), (:Movie {title: "1",tmdbId: "ajeje"}), (:Person {name: "baz"}), (:Person {name: "uno"}), (:Movie {name: "ajeje"}), (:Movie {title: "1",tmdbId: "due"}), (:Movie {title: "1",tmdbId: "ajeje"}), (:Person {name: "1"}), (:Movie {title: "1",tmdbId: "ajeje"}), (:Person {name: "foo"}), (:Person {name: "1"})] |
[[:REL], [:REL {idRel: 1}], [:REL {idRel: 1}], [:REL], [:REL], [:REL]]│ |
or:
MATCH path=(:Person)-[:REL]->(:Movie)
WITH collect(path) AS paths
CALL apoc.graph.filterProperties(paths, {_all: ['plotEmbedding', 'posterEmbedding', 'plot', 'bio']})
YIELD nodes, relationships
RETURN nodes, relationships
with the same result as above.