Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-10-2023 05:44 PM
Hi Team,
I am trying to add second edge but with same relationship name between two nodes as properties is different. But I am seeing only one edge and properties related to that edge.
For example I have two rows in csv with 5 columns shown below
startf stopf rservice code usage
340 350 Fixed Main Less
340 350 Fixed Second High
Query I am using to create database is as follows
01-10-2023 08:48 PM - edited 01-10-2023 08:52 PM
When you merge, it looks to see if the pattern already exists, and only creates it if does not. In your 'merge' to create the relationship, the nodes 'e' and 's' are the same for both rows of data, AND a relation of type INCLUDED_IN already exists for the second row. As a result, a new relationship is not created. What you need to do to trigger a new relationship to get created is include the relationship properties in the 'merge' so it sees the second relations as not existing (its different since you are specifying the value of the properties that must be to match) and creates it.
LOAD CSV WITH HEADERS FROM 'file:///test.csv' AS aloc
MERGE (e:RadioService {label: aloc.service})
MERGE (s:FrequencyBand {startFrequency: aloc.startf, stopFrequency: aloc.stopf})
MERGE (e)-[:INCLUDED_IN{Usage:aloc.usage, Code:aloc.code}]->(s)
In the above query, the INCLUDED_IN relationship doesn't match the second time because the specified properties are not the same. When you don't specify any properties, any existing relationship of that type would match. This is the same with nodes and their properties specified in the curly brackets (implicit 'where' clause with equality).
01-10-2023 09:20 PM
Thank you so much!!! It worked !!!
All the sessions of the conference are now available online