0
votes

Currently, I have a graph which I wanted to add multiple new same types of relationships. However, what I've gotten was the query created unnecessary relationships.

For example:

This is the initial graph

enter image description here

I wanted to add a new relationship BELONG_TO which link from Request node to Item Node. Notice that the relationship type name BELONG_TO has already existed which link Category node to Request node in the graph.

After execute the query below, This is what I got.

MATCH (i:Item), (r:Request)
MERGE (r)-[:BELONG_TO]->(i); 

enter image description here

As you can see the query creates extra unnecessary BELONG_TO relationships (from Category to Item and from Request to Request). What I wanted is to only create a BELONG_TO relationship which link Request Node to Item Node.

What I wanted:

enter image description here

Is there any solution for this? - The version of neo4j I'm using is 3.5.14 - Each node and relationship does not have any properties in it.

EDIT: Correction made on relationship name as type not label.

2
can you please share the output of this query on your graph ? MATCH (i:Item) ,(r:Request) RETURN labels(i),labels(r) LIMIT 100TheTeacher
@TheTeacher It returns the label names, which is Item and Request.Kyle_397
Each node has one label or multipleTheTeacher

2 Answers

2
votes
  1. In neo4j, a node has 0 or more "labels", and a relationship has exactly 1 "type" (NOT "label").
  2. It looks like the node in your visualization with the Category label also happens to have the Request label, and the node in your visualization with the Request label also happens to have the Item label. That would explain the behavior you see. If that is not intended, you should REMOVE all extraneous labels.
0
votes

I think you click the node, it will tell you what labels has on the node. The node which has Category also have the label Request.