cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicated (gray) nodes when creating new relationship

I am working together with a colleague, on a remote Graph DB. When I create nodes and relationships in my Neo4j browser, everything works and looks normal. But when he creates new relationships either with his Neo4j browser or via PHP Neo4j driver, using either CREATE or MERGE, instead of the new relationship - two duplicated (gray colored) nodes are introduced and relationship between them, and no relationship between the original nodes.

Is there any explanation for this problem, and how to resolve it?

1 ACCEPTED SOLUTION

Hi,
that sounds like he is not using a MATCH statement before he is creating or merging. So, I guess the command your colleague is using kind of looks like this:

MERGE (a:Node {id:5})-[:IS_CONNECTED_TO]->(b:Node {id:6})

Now, even if there are nodes a and b with the desired ids, this will create two new nodes which are connected and not connect the existing ones.
Instead of that your colleague should use

MATCH (a:Node {id:5}), (b:Node {id:6})
MERGE (a)-[:IS_CONNECTED_TO]->(b)

That also explains the "grayness" of the nodes. If there are certain labels missing, then they are not coloured in the colouring scheme that applies to all other nodes.

I hope this helps.
Regards,
Elena

View solution in original post

2 REPLIES 2

Hi,
that sounds like he is not using a MATCH statement before he is creating or merging. So, I guess the command your colleague is using kind of looks like this:

MERGE (a:Node {id:5})-[:IS_CONNECTED_TO]->(b:Node {id:6})

Now, even if there are nodes a and b with the desired ids, this will create two new nodes which are connected and not connect the existing ones.
Instead of that your colleague should use

MATCH (a:Node {id:5}), (b:Node {id:6})
MERGE (a)-[:IS_CONNECTED_TO]->(b)

That also explains the "grayness" of the nodes. If there are certain labels missing, then they are not coloured in the colouring scheme that applies to all other nodes.

I hope this helps.
Regards,
Elena

Hi,

it seems this solves our problem - thank you!

Regards,
Matjaz