Search code examples
propertiesneo4jcypherrelationships

Neo4j compare relationship properties


I need to make an optional match on relationship properties of r1 and r2.

r1 is n layers deep so I'm getting the error:

"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

How can I compare r1.value to r2.value when I don't know the value upfront?

Thanks!


Solution

  • 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