Neo4j 比较关系属性
Neo4j compare relationship properties
我需要对 r1 和 r2 的关系属性进行可选匹配。
r1 是 n 层深,所以我收到错误:
"Type mismatch: expected Map, Node or Relationship but was
Collection"
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE r1.value = v2.value
RETURN b,r2,c
当我事先不知道值时,如何比较 r1.value 和 r2.value?
谢谢!
MATCH (a:node{x:"foo"})-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
UNWIND r1 as r
WITH b, r2, c, r
WHERE r.value = r2.value
RETURN b,r2,c
我想这就是您要找的:
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE last(r1).value = v2.value
RETURN b,r2,c
解释:r1
是 collection。这完全合乎逻辑,因为您指定的是任意长度。
因此,如果您需要将此链中的 last 关系与某些特定关系进行比较,您可以使用 last
函数。
我需要对 r1 和 r2 的关系属性进行可选匹配。
r1 是 n 层深,所以我收到错误:
"Type mismatch: expected Map, Node or Relationship but was Collection"
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE r1.value = v2.value
RETURN b,r2,c
当我事先不知道值时,如何比较 r1.value 和 r2.value?
谢谢!
MATCH (a:node{x:"foo"})-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
UNWIND r1 as r
WITH b, r2, c, r
WHERE r.value = r2.value
RETURN b,r2,c
我想这就是您要找的:
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE last(r1).value = v2.value
RETURN b,r2,c
解释:r1
是 collection。这完全合乎逻辑,因为您指定的是任意长度。
因此,如果您需要将此链中的 last 关系与某些特定关系进行比较,您可以使用 last
函数。