在下图中,我如何使用绿色节点“Qualification”和“New York”作为条件来匹配规则1和规则2?
帮助我理解为什么以下Cypher查询不起作用:
MATCH
(r:Rule),
(r)-[w1:When*]->(c:State{instanceName:"New York"}),
(r)-[w2:When*]->(c2:Service{instanceName:"Qualification"})
RETURN * LIMIT 50
此查询仅返回规则2,而不返回规则1.
每个查询都单独工作并返回预期结果:
MATCH
(r:Rule),
(r)-[w2:When*]->(c2:Service{instanceName:"Qualification"})
RETURN * LIMIT 50
MATCH
(r:Rule),
(r)-[w1:When*]->(c:State{instanceName:"New York"})
RETURN * LIMIT 50
答案 0 :(得分:1)
由于单个MATCH
子句中的uniqueness关系,查询不返回规则1。在您的示例中,When
和Rule 1
之间的Instance
关系对于两个路径都是相同的,并且只返回其中一个。
要解决此问题,请使用两个单独的MATCH
子句。
MATCH
(r:Rule),
(r)-[w1:When*]->(c:State {instanceName: "New York"}),
MATCH
(r)-[w2:When*]->(c2:Service {instanceName: "Qualification"})
RETURN *
LIMIT 50
答案 1 :(得分:0)
使用单独的模式进行Somtehing:
MATCH (r:Rule)
MATCH (r)-[w1:When*]->(c:State{instanceName:"New York"})
MATCH (r)-[w2:When*]->(c2:Service{instanceName:"Qualification"})
RETURN * LIMIT 50