1
votes

I am having a problem creating a JOIN (MATCH) relationship. I am using the Neo4j example for the Northwinds graph database load as my learning example.

I have 2 simple CSV files that I successfully loaded via LOAD CSV FROM HEADERS. I then set 2 indexes, one for each entity. My final step is to create the MATCH (JOIN) statement. This is where I am having problems.

After running the script, instead of telling me how many relationships it created, my return message is "(no changes, no records)". Here are my script lines:

LOAD CSV WITH HEADERS FROM 'FILE:///TestProducts.csv' AS row
CREATE (p:Product)
SET p = row

Added 113 labels, created 113 nodes, set 339 properties, completed after 309 ms.

LOAD CSV WITH HEADERS FROM 'FILE:///TestSuppliers.csv' AS row
CREATE (s:Supplier)
SET s = row

Added 23 labels, created 23 nodes, set 46 properties, completed after 137 ms.

CREATE INDEX ON :Product(productID)

Added 1 index, completed after 20 ms.

CREATE INDEX ON :Supplier(supplierID)

Added 1 index, completed after 2 ms.

MATCH (p:Product),(s:Supplier)
WHERE p.supplierID = s.supplierID
CREATE (s)-[:SUPPLIES]->(p)

(no changes, no records)

Why? If I run the Northwinds example, with the example files, it works. It says 77 relationships were created. Also is there any way to see database structure? How can I debug this issue? Any help is greatly appreciated.

2

2 Answers

1
votes

I think you may be using the wrong casing for the property names. The NorthWind data uses uppercased first letters for its property names.

Try using ProductID and SupplierID in your indexes and the MATCH clause.

0
votes

Thanks for all the suggestions. With Neo4j there are always multiple ways to solve the problem. I did some digging and found a rather simple solution.

MATCH (a)-[r1]->()-[r3]->(b) CREATE UNIQUE (a)-[:REQUIRES]-(b);

Literal Code (for me) is: MATCH (a:Application)-[:CONSISTS_OF]->()-[:USES]->(o:Object) CREATE UNIQUE (a)-[:REQUIRES]-(o);

This grouped the relationships (n2) and created a virtual relationship, making the individual n2 nodes redundant for the query.

Namaste Everyone! Dean