Hi,
i have a trade network between the world countries with the various product codes represented as a relationship property. Furthermore, there are several node properties as well.
My goal is to combine two cypher queries into one, where the new property will be set for the EU countries (nodes with the EU property) which are trading one specific product.
What i got until now:
1.) Defining node property (all countries which trade this specific good are included)
MATCH (c1:Country)-[r:EXPORTED]->(c2:Country) WHERE r.ProductHSCode="300220"
SET c1.Product300220='YES', c2.Product300220='YES'
RETURN count(c1)
2.) Virtualizing graph
CALL gds.graph.create.cypher(
'graf',
'MATCH (c:Country) WHERE c.Product300220="YES" RETURN id(c) AS id, labels(c) AS labels',
'MATCH (c1:Country)-[r:EXPORTED]->(c2:Country) WHERE r.ProductHSCode="300220" RETURN id(c1) AS source, id(c2) AS target, r.ProductQuantity AS ProductQuantity, r.ProductValue AS ProductValue, type(r) AS type')
3.) Setting the property for the EU countries
MATCH (c:Country)
WHERE c.CountryISO3Letter IN ['AUT','BGR','HRV','CYP','CZE','DNK','EST','FIN','FRA','GRC','HUN','IRL','ITA','LVA','LTU','LUX','MLT','NLD','POL','PRT','ROU','SVK','SVN','ESP','SWE']
SET c.EU='YES'
4.) I need a query which will satisfy two conditions - product code = "300220" (relationship property) and every EU country (node property).
This doesn't work:
CALL gds.graph.create.cypher(
'grafEU',
'MATCH (c:Country) WHERE c.Product300220="YES" AND c.EU="YES" RETURN id(c) AS id, labels(c) AS labels',
'MATCH (c1:Country)-[r:EXPORTED]->(c2:Country) WHERE r.ProductHSCode="300220" RETURN id(c1) AS source, id(c2) AS target, r.ProductQuantity AS ProductQuantity, r.ProductValue AS ProductValue, type(r) AS type')
because:
Failed to invoke procedure
gds.graph.create.cypher
: Caused by: java.lang.IllegalArgumentException: Failed to load a relationship because its source-node with id 237 is not part of the node query or projection. To ignore the relationship, set the configuration parametervalidateRelationships
to false.