-
Notifications
You must be signed in to change notification settings - Fork 6
ImportingIntentGraph
#Create constraint by loading CSV
CREATE CONSTRAINT ON (c:Intent) ASSERT c.name IS UNIQUE; CREATE CONSTRAINT ON (c:Term) ASSERT c.name IS UNIQUE;
USING PERIODIC COMMIT 50
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
= 'term'
MERGE (n:Term {name:Line.name})
SET n.nodeid = Line.node id
return n
USING PERIODIC COMMIT 50
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
= 'intent'
MERGE (n:Intent {name:Line.name})
SET n.nodeid = Line.node id
return n
USING PERIODIC COMMIT 50
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
= 'domain'
MERGE (n:Domain {name:Line.name})
SET n.nodeid = Line.node id
return n
Creates all nodes from the CSV, you need add one FOREACH clause for each node type, which is possible in the CSV
USING PERIODIC COMMIT 50
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
IS NOT NULL
FOREACH(ignoreMe IN CASE WHEN Line.node type
= 'term' THEN [1] ELSE [] END | MERGE (n:Term {name:Line.name}) SET n.nodeid = Line.node id
)
FOREACH(ignoreMe IN CASE WHEN Line.node type
= 'intent' THEN [1] ELSE [] END | MERGE (n:Intent {name:Line.name}) SET n.nodeid = Line.node id
)
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
IS NOT NULL
MATCH (i:Intent {name:Line.name})
MATCH (pi:Domain {nodeid:Line.parent node id
})
call apoc.create.relationship(i, Line.parent relation
,{weight:Line.weight}, pi) YIELD rel as r
return i,pi,r
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
IS NOT NULL
MATCH (n:Term {name:Line.name})
MATCH (pn:Intent {nodeid:Line.parent node id
})
call apoc.create.relationship(n, Line.parent relation
,{weight:Line.weight}, pn) YIELD rel as r
return n, pn, r
LOAD CSV WITH HEADERS FROM "file:///javaConceptsToIntent.csv" AS Line
WITH Line
WHERE Line.node type
IS NOT NULL
MATCH (n:Term {name:Line.name})
MATCH (pn:Term {nodeid:Line.parent node id
})
call apoc.create.relationship(n, Line.parent relation
, {weight:Line.weight}, pn) YIELD rel as r
return n, pn, r