apoc.create.removeLabels过程Cypher 25 中已弃用
|
此过程已弃用。如需动态移除标签,请改用 Cypher 的 |
语法 |
|
||
描述 |
从给定的 |
||
输入参数 |
名称 |
类型 |
描述 |
|
|
要移除标签的节点。 |
|
|
|
要从给定节点中移除的标签。 |
|
返回参数 |
名称 |
类型 |
描述 |
|
|
更新后的节点。 |
|
使用 Cypher 移除标签
在 Cypher 中无需使用 APOC 即可动态引用标签。
用于动态移除标签的 Cypher 语法
REMOVE n:$(label)
动态计算出的标签必须求值为 STRING 或 LIST<STRING>。有关更多信息,请参阅 Cypher 手册 → 动态移除标签。
使用示例
本节中的示例基于以下示例图
CREATE (jennifer:Person:US {name: "Jennifer", community: 1, partition: 4})
CREATE (karin:Person:US {name: "Karin", community: 4, partition: 2})
CREATE (mark:Person:UK {name: "Mark", community: 3, partition: 3});
以下示例演示了如何同时使用 APOC 和 Cypher 从所有节点中移除除 Person 之外的所有标签
apoc.create.removeLabels
CALL db.labels()
YIELD label WHERE label <> "Person"
WITH collect(label) AS labels
MATCH (p:Person)
WITH collect(p) AS people, labels
CALL apoc.create.removeLabels(people, labels)
YIELD node
RETURN node, labels(node) AS labels
使用 Cypher 的动态标签
CALL db.labels()
YIELD label WHERE label <> "Person"
WITH collect(label) AS labels
MATCH (p:Person)
REMOVE p:$(labels)
RETURN p, labels(p) AS labels
| 节点 | 标签 |
|---|---|
(:Person {name: "Jennifer", partition: 4, community: 1}) |
["Person"] |
(:Person {name: "Karin", partition: 2, community: 4}) |
["Person"] |
(:Person {name: "Mark", partition: 3, community: 3}) |
["Person"] |