Hello, For testing purpose I am trying to make relationship two nodes . One node has Customer label and other node as Device label
Node creation is done. I am. facing problem to make relationship between two nodes
RELATIONSHIP,IDENTITY_ID,DEVICE_ID
HAS_DEVICE,22q,1010k
HAS_DEVICE,q22,1020k
HAS_DEVICE,ac23,1030k
HAS_DEVICE,dfd,1050k
HAS_DEVICE,22q,1070k
HAS_DEVICE,ac23,1090k
This is my relationship device.csv file . The identity_id values exists in the CUSTOMER labeled nodes, and DEVICE_ID values exist in DEVICE labelled node
|IDENTITY_ID|DIVISION|
|---|---|
|22q|KHULNA|
|q22|DHAKA|
|ac23|RANGPUR|
|dfd|KHULNA|
|123g|MYMENSINGH|
|eo89|CHITTAGONG|
|ere3|SYLHET|
|lo1o3|DHAKA|
|90de|CHITTAGONG|
|er02|CHITTAGONG|
|22q|KHULNA|
|DEVICE_ID|DEVICE_NAME|
|---|---|
|1010k|SAMSUNG|
|1020k|APPLE|
|1030k|SONY|
|1050k|OPPO|
|1070k|ONEPLUS|
|1090k|SYMPHONY|
|1080k|NOKIA|
|1015k|ZTE|
|1025k|XIAOMI|
|1030k|XIAOMI pro|
so these are my values of customer.csv and device.csv
so the idea is I will create relationship between two nodes based on IDENTITY_ID and DEVICE_ID in relationship files.
I have tried several way to do this
since it is test case but this code will be applied in big size of data
LOAD CSV WITH HEADERS FROM "file:///relationship_device.csv" AS row
MATCH (f:CUSTOMER), (s:DEVICE)
WHERE f.IDENTITY_ID = row.IDENTITY_ID
AND s.DEVICE_ID = row.DEVICE_ID
CALL apoc.create.relationship(f, row.RELATIONSHIP,{}, s) YIELD rel
RETURN rel
using apoc library
CALL apoc.periodic.iterate('
load csv with headers from "file:///relationship_device.csv" AS row return row ','
MATCH (c:CUSTOMER {IDENTITY_ID: row.IDENTITY_ID})
MATCH (d:DEVICE{DEVICE_ID: row.DEVICE_ID})
MERGE(c)-[r:HAS_DEVICE]->(d)
',{batchSize:1000, iterateList:true, parallel:true})
LOAD CSV WITH HEADERS FROM "file:///relationship_device.csv" AS line
MATCH (customer:CUSTOMER {IDENTITY_ID:line.IDENTITY_ID}),(device:DEVICE {DEVICE_ID:line.DEVICE_ID})
CREATE (customer)-[ :HAS_DEVICE{RELATIONSHIP: line.RELATIONSHIP}]->(device)
so far no relationship is created by this two nodes.What thing I am missing here.Using apoc solution will be good for future development. Any help will be highly appreciated