Search code examples
cyphermemgraphdbopencypher

When executing the CREATE query I get the error about Bidirectional relationship


When I execute the query CREATE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f;, I get the following error:

Error: Query failed: Bidirectional relationship are not supported when creating an edge

If I use MERGE instead of CREATE, the relationship is created:

MERGE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f

Why is this so?


Solution

  • Assuming that Memgraph is following the openCypher specification, for a MERGE where no direction is specified, the spec allows the implementation to pick a direction. While this means the query will work, it's going to be better (and safer) to provide an explicit edge direction.

    The specific guidance is given on Page 119 of the document linked above, where it states:

    MERGE can also be used with an undirected relationship. When it needs to create a new one, it will pick a direction.