Neo4j匹配路径排除具有特定标签的节点 [英] Neo4j match path exclude node with certain label
本文介绍了Neo4j匹配路径排除具有特定标签的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Neo4j中检索路径时遇到问题,排除了某些标签.
I am having a issue to retrieve path in neo4j exclude certain label.
敌人的例子,我有
-->(h)-->(j)
/
(a)-->(b)-->(c)-->(d)-->(i)
\
-->(f)-->(g)
带有h
节点的
带有Deleted
标签.
我有疑问
MATCH path = (n)-[*]->(child) where id(n)={id of node a} and NOT child:Deleted RETURN path
然后,我希望此查询返回完整路径,但排除节点h
的子树,因为节点h
为Deleted
.
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)
但是查询似乎无法正常工作.
But the query seems not working.
有人可以帮我吗?
谢谢
推荐答案
对我有用的是对路径中节点的列表理解:
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屋!
查看全文