I am having a challenge merging nodes and also setting a property at the same time. Although it works, some nodes are still very independent instead of linking to other nodes. My objective is to connect the nodes with similar identities.
______
"LOAD CSV WITH HEADERS FROM $path AS row "
"MERGE (fo:food {food_name: row.Food_name}) "
"MERGE (ma:materials {materials: row.Material}) "
"MERGE (o:origin {origin: row.Origin}) "
Please can anyone explain the reason for the duplicates in this case study? I and A are duplicated (independent nodes), while connected and at the same time, the materials are also duplicated while also linked as instructed.
I see one issue in your queries. In the first one you label is materials and the second it is material. Thus, the merge fails and creates new nodes. They are not duplicates, but have different labels.
the other observation is you have multiple rows with the same origin, thus, the values set will only reflect the last row with the same origin.
Sure, that is fine. the merge will either match an existing node or create a new one to match
You can either delete the wrong ones, or correct them. Which ever option is easiest. You can remove a label with ‘remove n:LabelToRemove’, where ‘n’ is the node’s binding variable. You can add a label with ‘set n:LabelToAdd’
The relationships between two nodes are fixed, regardless of you changing the labels on either node. You have to manually add/remove relationships.
you can either delete all the nodes created and run all three corrected queries, or delete the extra ones, fix the label if necessary, and run the 2nd and 3rd corrected queries.