0

I have following code :

 var q = new CypherFluentQuery(client) as ICypherFluentQuery;
        q = q.OptionalMatch("(n:subject)-[r4:SCP_IN_SC]-(sc:Spec)");
        q = q.OptionalMatch("(sc)-[r5:SCP_IN_SC]-(p)");
        q = q.OptionalMatch("(p)-[r6:SCP_IN_SCT]-(t:Tag)");
        q = q.OptionalMatch("(t)-[r7:SCP_IN_SCT]-(n)");
        q = q.OptionalMatch("(p)-[r8:SCP_IN_SCC]-(c:Catalog)");

how can I find which optional match was matched in query result ?

1 Answers1

0

Any OPTIONAL MATCH (not limited to 1, obviously) which matched will result in a non-null element in the result, i.e. sc is null if the first one didn't match, an actual node if it matched.

As a side node, hopefully you have more constraints on the nodes (extra labels, WHERE clause, etc.), because otherwise it looks like p and n are actually the same node.

Frank Pavageau
  • 11,477
  • 1
  • 43
  • 53