I have imported a table with thousands of equipments. Then another table is imported with types of equipment that contain about 20 types.
When I wrote a cypher request below to link them, Neo4j warned me about a Cartesian product. Is there a better way to create associations? Should I do this during CSV import?
MATCH (te:Equipment_Type),(e:Equipment)
WHERE te.type_id = e.type_id
CREATE (e)-[:TYPE_OF]→(te)
Update
I tried what Brian attached during the CSV import and worked like a charm.
- First imported equipment types;
- Then they are created and indexed on the Equipment (type_id);
- Changed search code during CSV import.
From Neo4j Console:
100812 shortcuts were added, 100812 nodes were created, 414307 objects were installed, 100812 relationships were created, the operator executed in 33902 ms.
Code:
CREATE INDEX ON :Equipment(type_id)
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "http://localhost/Equipments.csv" AS row
MERGE (e:Equipment {eqp_id: row.eqp_id, name: row.name, type_id: row.type_id})
WITH e, row
MATCH (te:Equipemnt_Type)
WHERE te.type_id = row.type_id
CREATE (e)-[:TYPE_OF]->(te)