Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-24-2019 07:38 AM
Hi there
I am trying to create a relationship between two groups of nodes to indicate the association type between Clients (node type 1) and Related Parties (node type 2). I have successfully added both node types with their properties and now would like to create a relationship between the Clients and the Related Parties i.e. Related Party XYZ is a "parent company" of Client Company ABC (relationship is in inverted commas and may differ for different relationships - field RELATED PARTY_TYPE). I would like the Related Party type to be on the arrow in the graph and to add properties to the relationship so that when the relationship is clicked on, the properties appear. My relationship CSV looks like the following;
CLIENT_ID, RELATED PARTY_ID, RELATED PARTY_TYPE, PERCENT_OWNED, UBO_SHAREHOLDING_TYPE, SHAREHOLDING_LEVEL, UBO_ROLES
49453, 664, Parent Company, 24.5, Indirect, 4, Party in Ownership Chain
I have tried many Cypher variations and none have worked so far including the below but I get a Cartesian product warning " This query builds a cartesian product between disconnected patterns."
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM 'file:///Relationships.csv' AS csvLine
MATCH (c:Client {CLIENT_ID: toInteger(csvLine. TECH_CLIENT_ID)}),(r:RelatedParty {RELATEDPARTY_ID: toInteger(csvLine. RELATEDPARTY_ID)})
CREATE (c)-[:AssociatedWith {RELATEDPARTY_TYPE: csvLine.RELATEDPARTY_TYPE}]->(r)
Any help would be much appreciated.
10-24-2019 08:27 AM
I have tried the below but I get a Cartesian product warning " This query builds a cartesian product between disconnected patterns."
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM 'file:///Relationships.csv' AS csvLine
MATCH (c:Client {CLIENT_ID: toInteger(csvLine. TECH_CLIENT_ID)}),(r:RelatedParty {RELATEDPARTY_ID: toInteger(csvLine. RELATEDPARTY_ID)})
CREATE (c)-[:AssociatedWith {RELATEDPARTY_TYPE: csvLine.RELATEDPARTY_TYPE}]->(r)
10-26-2019 04:02 AM
In this case you can safely ignore the warning. Since you do match on an id both for Client
and RelatedParty
- which should give you 1 result each. So the cartesian product is 1 x 1 = 1.
11-03-2019 12:56 PM
Hi Stefan
Thanks for your response. Unfortunately the cypher query does not work as Neo4j can't execute it fully. As seen below the 'loading' icon appears and the relationships are never formed (even after left 'loading' for days). Is there another query you are able to suggest to create relatioships between two types of nodes?
Thanks and regards
Rebecca
11-03-2019 08:13 PM
There are some issues with your .csv file and the Cypher code.
1: The header and data lines have a space after comma.
2: Not referencing the headers correctly. RELATED_PARTY_ID is referenced as RELATEDPARTY_ID in the MATCH statement.
Here is how you can fix this:
.csv file:
TECH_CLIENT_ID, RELATED_PARTY_ID, RELATED_PARTY_TYPE, PERCENT_OWNED, UBO_SHAREHOLDING_TYPE, SHAREHOLDING_LEVEL, UBO_ROLES
49453, 664, Parent Company, 24.5, Indirect, 4, Party in Ownership Chain
-See the spaces after comma in the headers and data lines. I don't know whether the first column also has space before. But, for consistency I included the space.
Now when you refer the headers you need to use back tick before and after the column name to include the empty space.
Here is the corrected Cypher queries:
LOAD CSV WITH HEADERS FROM 'file:/rels.csv' AS csvLine
MERGE (c:Client {CLIENT_ID: toInteger(csvLine. TECH_CLIENT_ID
)})
MERGE (r:RelatedParty {RELATEDPARTY_ID: toInteger(trim(csvLine. RELATED_PARTY_ID
))})
return c, r
Result:
Create relationship:
LOAD CSV WITH HEADERS FROM 'file:/rels.csv' AS csvLine
MATCH (c:Client {CLIENT_ID: toInteger(csvLine. TECH_CLIENT_ID
)})
MATCH (r:RelatedParty {RELATEDPARTY_ID: toInteger(trim(csvLine. RELATED_PARTY_ID
))})
CREATE (c)-[:AssociatedWith {RELATEDPARTY_TYPE: csvLine. RELATEDPARTY_TYPE
}]->(r)
return c, r
result:
11-04-2019 01:24 AM
Hi ameyasoft
Thanks for your message - but those issues are only within my post due to rushed typing and not my cypher query. The query is being executed, the relationship query is not giving any errors but as seen in the image above but is taking hours/days to load.
Regards
Rebecca
05-17-2020 08:03 AM
Hi, I am experiencing the very same issue. I am running on a docker instance and I thought it might be a memory/swap issue. However the server has plenty of memory, but I see the Java runtime running at 100%. Still not progress after hours.
Any more suggestions around? Is there a way to see the progress?
All the sessions of the conference are now available online