[英]Excluding paths from Neo4j Cypher allShortestPaths() that contain a given node, or given relationship
What is the best way, given the following Neo4j Cypher query, for the returned collection of paths not to contain any path that contains an Item node whose itemId is equal to “Q5”? 给定以下Neo4j Cypher查询,对于返回的路径集合不包含任何包含itemId等于“ Q5”的Item节点的路径,最佳方法是什么?
MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) )
RETURN p;
Also, what is the best way, given the above query, for the returned collection of paths not to contain any path that contains a relationship whose propId is equal to “P31”? 另外,给定上述查询,对于返回的路径集合不包含任何包含其propId等于“ P31”的关系的路径,最好的方法是什么?
Thanks, James Weaver 谢谢,詹姆斯·韦弗
The returned collection of paths does not contain any path that contains an Item node whose itemId is equal to “Q5”: 返回的路径集合不包含任何包含itemId等于“ Q5”的Item节点的路径:
MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) ) WHERE NONE(x IN NODES(p) WHERE x:Item AND x.itemId = "Q5") RETURN p;
The returned collection of paths does not contain any path that contains a relationship whose propId is equal to “P31”: 返回的路径集合不包含任何包含其propId等于“ P31”的关系的路径:
MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) ) WHERE NONE(x IN RELATIONSHIPS(p) WHERE x.propId = "P31") RETURN p;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.