【问题标题】:How to return end-node of a relationship in Cypher-query?如何在 Cypher-query 中返回关系的结束节点?
【发布时间】:2012-04-08 13:37:17
【问题描述】:

按照 Cypher-Query 从匹配的关系索引返回所有关系:

start r=relationship:concept_contained_in_report('concept_id:2') return r

如何返回这些关系的所有端节点而不是关系本身?

我会期待类似的东西

 start r=relationship:concept_contained_in_report('concept_id:2') return r.end

但这不起作用,因为 end(endnode)不是关系的属性。

谢谢 乔格

【问题讨论】:

    标签: neo4j cypher


    【解决方案1】:

    你可以试试

    start r=relationship:concept_contained_in_report('concept_id:2')
    match ()-[r]->endNode
    return endNode
    

    基本上,匹配关系的开始和结束。您不关心开头,因此不要为其分配标识符。为结束节点分配一个标识符并返回它。

    【讨论】:

      【解决方案2】:

      或者在 Neo4j 2.0+ 中,你也可以试试下面的代码:

      start r=relationship:concept_contained_in_report('concept_id:2')
      return endNode(r) as eNode
      

      它们提供了一个非常方便的功能,嗯。

      【讨论】:

      • 是否可以只返回匹配特定标签的endNodes?我不想要所有的 endNode,只想要那些有特定标签的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多