|| apoc.nodes.relationship.types - APOC 核心文档 - Neo4j 文档

apoc.nodes.relationship.types

详情

语法

apoc.nodes.relationship.types(nodes [, types ])

描述

返回给定 LIST<NODE> 值中不同 RELATIONSHIP 类型的 LIST<STRING>

参数

名称

类型

描述

nodes

ANY

要返回连接关系类型的节点。

types

STRING

如果不为空,提供要返回的关系类型允许列表。关系类型使用 APOC 的关系方向模式语法表示;[<]RELATIONSHIP_TYPE1[>]|[<]RELATIONSHIP_TYPE2[>]|…​。默认值是:``。

返回

LIST<ANY>

输出参数

名称 类型 描述

value

LIST<MAP>

一个包含 MAP 值的 LIST<MAP>,其键为:"node" → NODE 和 "types" → LIST<STRING>,包含每种类型的 STRING 值。

使用示例

本节示例基于以下示例图

MERGE (michael:Person {name: "Michael"})
WITH michael
CALL {
    WITH michael
    UNWIND range(0, 100) AS id
    MERGE (p:Person {name: "Person" + id})
    MERGE (michael)-[:KNOWS]-(p)
    RETURN count(*) AS friends
}

CALL {
    WITH michael
    UNWIND range(0, 50) AS id
    MERGE (p:Person {name: "Person" + id})
    MERGE (michael)-[:FOLLOWS]-(p)
    RETURN count(*) AS follows
}

RETURN friends, follows;
结果
friends follows

101

51

MATCH (p1:Person)
WHERE p1.name IN ["Michael", "Person30", "Person60"]
WITH collect(p1) AS people
UNWIND apoc.nodes.relationship.types(people, "KNOWS>|FOLLOWS") AS output
RETURN output;
结果
输出

{node: (:Person {name: "Michael"}), types: ["KNOWS", "FOLLOWS"]}

{node: (:Person {name: "Person30"}), types: ["FOLLOWS"]}

{node: (:Person {name: "Person60"}), types: []}

© . This site is unofficial and not affiliated with Neo4j, Inc.