1
votes

When I try to add new nodes with labels (Phone, Name) that don't exist yet with a relationship to an existing node the nodes and relationships are not being created.

This is the before and after state with one existing relationship:

MATCH (n:Identity)-[a:ATTR]->(attr) RETURN *

graph

And this is the mutation query:

MATCH (n:Identity {id:'4a028061-8dde-4f64-80c9-ae048e3f81fc'})
MERGE (n)-[na:ATTR]->(name:Name {val: 'John Smith'})
MERGE (n)-[pa:ATTR]->(p:Phone {val:2326410083})
RETURN *

I know this question is similar to Neo4J - Merge statement not creating new nodes with a relationship but, in my case, I am using filters on the nodes. What's am I missing?

1

1 Answers

1
votes

Looks like the :Identity node you're trying to match to doesn't exist in the graph.

From your query, you're looking for an identity node with id:'4a028061-8dde-4f64-80c9-ae048e3f81fc', but in the graph image you supplied, if we assume the cut off caption is the id of the identity node, we can tell it starts with:'44b7'

Now it could be that the node you're trying to match on does exist, but doesn't have any outgoing :ATTR relationship (that would explain why it wouldn't be returned by your query), but that's unconfirmed. Does a node with id:'4a028061-8dde-4f64-80c9-ae048e3f81fc' exist in your graph? You haven't shown us that, and if no such node exists then the match would fail, and then there are no rows left for the remaining MERGEs to execute upon.