Neo4j 匹配路径排除具有特定标签的节点 [英] Neo4j match path exclude node with certain label

查看:16
本文介绍了Neo4j 匹配路径排除具有特定标签的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Neo4j 中检索路径时遇到问题,排除某些标签.

I am having a issue to retrieve path in neo4j exclude certain label.

例如,我有

               -->(h)-->(j)
              /
(a)-->(b)-->(c)-->(d)-->(i)
                   
         -->(f)-->(g)

with h 节点有一个 Deleted 标签.

with h node has a Deleted label.

我有疑问

MATCH path = (n)-[*]->(child) where id(n)={id of node a} and NOT child:Deleted RETURN path

然后我希望此查询返回完整路径但排除节点 h 的子树,因为节点 hDeleted.

then I want this query to return the full path but exclude the subtree of node h since node h is Deleted.

返回树应该是这样的

(a)-->(b)-->(c)-->(d)-->(i)
                   
         -->(f)-->(g)

但查询似乎不起作用.

谁能帮我解决这个问题.

Can any one help me with this.

谢谢

推荐答案

对我有用的是对路径中节点的列表理解:

What worked for me is a list comprehension over nodes in the path:

MATCH path = ()-[*]->()
WHERE NONE(n IN nodes(path) WHERE n:Deleted)
RETURN path

这篇关于Neo4j 匹配路径排除具有特定标签的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆