【问题标题】:Get results from relationships properties without square brackets?从没有方括号的关系属性中获取结果?
【发布时间】:2016-11-20 15:02:59
【问题描述】:

在 Cypher Neo4j 图形数据库中,我想在不带方括号的字符串中获取查询结果。 每次我从节点属性中检索信息时,我都会按预期以字符串形式获得结果,但是当我从关系中检索信息时,它会显示在方括号内。

MATCH (m:Movie {title:"The Matrix"})<-[r:ACTED_IN]-() return r.roles;

结果:

[Agent Smith]
[Morpheus]
[Trinity]
[Neo]

【问题讨论】:

    标签: database neo4j cypher graph-databases non-relational-database


    【解决方案1】:

    您得到方括号的原因是ACTED_IN 关系的roles 属性是list

    您可以使用UNWIND 将列表(包括单元素列表)扩展到行:

    MATCH (m:Movie {title:"The Matrix"})<-[r:ACTED_IN]-()
    UNWIND r.roles AS roles
    RETURN roles
    

    如果我在 tutorial 中提供的 Matrix 数据集上运行它,我会得到:

    ╒═══════════╕
    │roles      │
    ╞═══════════╡
    │Agent Smith│
    ├───────────┤
    │Emil       │
    ├───────────┤
    │Trinity    │
    ├───────────┤
    │Morpheus   │
    ├───────────┤
    │Neo        │
    └───────────┘
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-02
      相关资源
      最近更新 更多