Hello @oli ![]()
I think it's because your query is too long.
First, you should create UNIQUE CONSTRAINTS on nodes:
CREATE INDEX index_car_id IF NOT EXISTS FOR (n:Car) ON (n.carID)
CREATE INDEX index_event_id IF NOT EXISTS FOR (n:Event) ON (n.probe_id)
Then, you load Car nodes:
:auto USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///file_name.csv" AS line
WITH DISTINCT line.vin AS carid
MERGE (c:Car {carID: carid})
Then, you load Event nodes:
:auto USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///file_name.csv" AS line
WITH line.start_time AS st, line.end_time AS et, line.event as event, line.sub_id as sid
MERGE (e:Event {eventType: event, start_time: st, end_time: et, probe_id: sid})
Then, you load relations:
:auto USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///file_name.csv" AS line
WITH line.vin AS carid, line.sub_id as sid
MATCH (c:Car {carID: carid})
MATCH (e:Event {probe_id: sid})
CREATE (c)-[:takePlace]->(e)
You can also have a look at these posts:
- Load CSV with multiple relations one on the same two nodes
- How to make relationships from a csv on existing nodes and display their values on the edges?
Regards,
Cobra