简体   繁体   English

Neo4j/Cypher:具有关系属性过滤器的两个节点之间的所有路径

[英]Neo4j/Cypher: All paths between two nodes with a relationship property filter

I am trying to perform a query to retrieve all paths between two nodes a and b in which all the paths there is a relationship property fulfilled.我正在尝试执行查询以检索两个节点 a 和 b 之间的所有路径,其中所有路径都满足关系属性。

I have tried in many ways but I am not able to success.我尝试了很多方法,但我无法成功。

MATCH p=(o{value:"a"})-[r*]-(x{value:"b"}) where has(r.property) and r.property="foo" return p匹配 p=(o{value:"a"})-[r*]-(x{value:"b"}) 其中 has(r.property) 和 r.property="foo" 返回 p

relationship part i have changed to [r*..] and many other options but not working关系部分我已更改为 [r*..] 和许多其他选项但不起作用

The function shortestpath does not help me because I want not only the shortest but all the possibilities.函数 shortestpath 对我没有帮助,因为我不仅想要最短的,而且想要所有的可能性。

Can someone help me or tell me which is the error in the query?有人可以帮助我或告诉我查询中的错误是什么吗?

Thank you in advance.提前谢谢你。

What you're looking for is the ALL predicate on the relationships collection of the path :您正在寻找的是 path 的关系集合上的ALL谓词:

MATCH p=(o{value:"a"})-[r*]-(x{value:"b"})
WHERE ALL(x IN rels(p) WHERE x.property = "foo")
RETURN p

And please use labels !并请使用标签!

Could you add the property on the relation/edge?你能在关系/边上添加属性吗?

()-[r:label{property:"foo"}]->()

That would force an edge with a value for foo property.这将强制具有foo属性值的边。 I'm not a neo4j expert but interested why this would not work.我不是 Neo4j 专家,但对为什么这行不通很感兴趣。 Maybe you can post a mini-sample of the data for people to test it out with.也许你可以发布一个数据的小样本供人们测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM