简体   繁体   中英

Neo4j relationship creation

Neo4J 2.0.3 Community version Windows Server 2008 R2 ENT 64bit

Hi, Im new to Neo4j and have been trying to load some data and relationships, but have hit a snag. i have loaded 680,000 nodes using the load CSV command, and that works great.

USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM "file:/c:/Import/CSVsForImport/AMRentLine.csv" AS csvLine CREATE (p:AmRentLine { Rentid: csvLine.Rentid, Itemid: csvLine.Itemid, Name: csvLine.Name, Qty: tofloat(csvLine.Qty)})

Sample Data:

Rentid          Itemid       Name               Qty
0123-014160     18/0165-h   TRENCH RAMMER        52
0123-014165     18/0168-h   TRENCH RAMMER        65
4290-014167     18/0165-h   TRENCH RAMMER        43
4290-014188     10/0385-h   PERCUSSION DRILL      5
4290-014190     10/0385-h   PERCUSSION DRILL     28
4290-014197     11/0155-h   HEAVY DUTY DRILL      4

Then I loaded Itemtab

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/c:/Import/CSVsForImport/Itemtab.csv" AS csvLine
create (i:Itemtab {Itemid: csvLine.Itemid})

Sample Item data

Itemid
18/0165-h
18/0168-h
10/0385-h
11/0155-h
15/0230-h
11/0120-h
11/0170-h
26/0090-h
15/0225-h
71/6250-h
01/0110-h
18/0300-h
9940344-h
26/0120-h

Then I tried to create relationships

match (rl:AmRentLine),(it:Itemtab) where rl.Itemid = it.Itemid merge (it)-[:IsOnContract]->(rl)

this runs for hours and eventually finishes, in the Neo4j browser a relationship IsOnContract appears but when i try and query these relationships with

MATCH (a)-[:`IsOnContract`]->(b) RETURN a,b LIMIT 25

(Linkurious says there are 0 relationships BTW)

I get zero rows- ie the relationships dont exist.

Is there something i am doing wrong here?

I have also tried creating the relationships during the import of AmRentLine but with the same effect.

regards Colin

Colin,

I think you hit a memory issue. And a cross-product.

So for once you can perhaps up your memory in neo4j-wrapper.conf ?

create index on :AmRentLine(Itemid); create index on :Itemtab(Itemid);

Otherwise try to do the following:

match (rl:AmRentLine)
MATCH (it:Itemtab {ItemId:rl.ItemId})
merge (it)-[:IsOnContract]->(rl)
remove rl.ItemId
remove it.ItemId

or you can chunk up your work into smaller sections

match (rl:AmRentLine),(it:Itemtab) 
with rl,it
skip 200000 limit 100000
where rl.Itemid = it.Itemid 
merge (it)-[:IsOnContract]->(rl)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM