cypher多层关系查询,返回 所有关系边的id
发布于 7 年前 作者 heven0 12288 次浏览 来自 问答

cypher怎么查询多层关系的时候 怎么返回关系节点id?

想要实现的描述如下:

start n=node(1), n1=node(2) match p = n-[r*1…5]-n1 return id(n), id(n1)

怎么在return结果里返回id( r )?

2 回复

r是关系边,不止一个啊,r是个关系集合类型,用id(r)是无法返回的,可以用 reduce方法 start n=node(1), n1=node(2) match p = n-[r*1…5]-n1 with reduce(acc=’’ , index IN range(0, length®| acc+’-’+id(r[index]) ))AS rids, ', return id(n), id(n1),rids

上面是我大体写的,你再查下reduce方法的使用格式,这样就可以的

@pangguoming 好的,非常感谢!

回到顶部