apoc.graph.filterProperties
过程 Apoc 扩展
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
签名
apoc.graph.filterProperties(value :: ANY?, nodePropertiesToRemove = {} :: MAP? , relPropertiesToRemove = {} :: MAP?) :: ANY?
输出参数
| 名称 | 类型 |
|---|---|
节点 |
节点列表? |
relationships |
关系列表? |
nodePropertiesToRemove 和 relPropertiesToRemove 参数是映射表,其键为标签/关系类型,值为要从虚拟实体中移除的属性列表。这两个参数的键也可以设为 _all,这意味着每个标签/关系类型的属性都会被过滤。
使用示例
假设有以下数据集
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"})
我们可以执行
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
| 节点 | 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]]│ |
或
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
结果与上述相同。