【发布时间】:2020-08-23 20:04:59
【问题描述】:
我有 2 个问题。
1) 如何在属性列表中搜索所有关系并过滤 PID (ProductID)。
2) 如何搜索路径中的所有节点并在属性列表中过滤 PID (ProductID)
Here is what the graph look like
以下查询成功过滤路径,但我已将列表索引硬编码为 0
match path= (n1) -[rel*..10] ->(n2)
where all(rel in relationships(path)where rel.PID[0]=2)
return path
1) 如何在列表中搜索所有关系并过滤 PID (ProductID)
我尝试使用以下查询将硬编码索引值 PID[0] 替换为循环,但它没有返回任何内容。请帮助我了解查询有什么问题。
match path= (n1) -[rel*..10] ->(n2)
where all(rel in relationships(path)where [x in rel.PID where x=2])
return rel
2) 如何搜索路径中的所有节点并在列表中过滤 PID (ProductID)
同样,节点的查询是什么。
以下查询运行成功,但我已将列表索引硬编码为 0
match path= (n1:Product) -[rel*..10] ->(n2)
where all(r in nodes(path)where r.PID[0]=1)
return path
替换了硬编码的索引值 PID[0],它什么也没给我。
match path= (n1:Product) -[rel*..10] ->(n2)
where all(r in nodes(path)where [x in r.PID where x=1])
return nodes(path)
任何帮助将不胜感激。
谢谢
图表的密码
CREATE
(`0` :Supplier {name:"Supplier1"}) ,
(`3` :Airport {name:"Johannesburg",city:"Johannesburg",country:"South Africa",PID:'[1,2]'}) ,
(`5` :Warehouse {name:"WareHouse1",PID:'[1,2]'}) ,
(`8` :Airport {name:"Dusseldorf",city:"Dusseldorf",PID:'[1]'}) ,
(`9` :Airport {name:"Brisbane",city:"Brisbane",country:"Australia",PID:'[1]'}) ,
(`10` :Airport {name:"Perth",city:"Perth",country:"Australia",PID:'[1,2]'}) ,
(`11` :Product {name:"Product1",PID:'[2]'}) ,
(`12` :Product {name:"Product 2",PID:'[2]'}) ,
(`20` :Airport {name:"Frankfurt",city:"Germany",country:"Germany",PID:'[2]'}) ,
(`9`)-[:`TRANSPORT` {PID:'[1]'}]->(`10`),
(`20`)-[:`TRANSPORT` {PID:'[2]'}]->(`3`),
(`3`)-[:`TRANSPORT` {PID:'[2]'}]->(`10`),
(`5`)-[:`RECEIVES` ]->(`10`),
(`12`)-[:`TRANSPORT` {PID:'[2]'}]->(`20`),
(`0`)-[:`TRANSPORT` ]->(`12`),
(`0`)-[:`TRANSPORT` ]->(`11`),
(`11`)-[:`TRANSPORT` {PID:'[2]'}]->(`8`),
(`8`)-[:`TRANSPORT` {PID:'[1]'}]->(`3`),
(`3`)-[:`TRANSPORT` {PID:'[1]'}]->(`9`)
【问题讨论】: