Reputation: 1239
From neo4d lessons learned example from NASA
References a github project showing how NASA used Neo4J to create a lessons learned database. It is from 2015 and I've been struggling to get the Cypher code running on newer versions of Neo4j (I'm learning as I go).
The error message I am getting is My modified version is below.
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/llis.csv'
AS line
WITH line
Limit 1
RETURN line
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/llis.csv' AS line
WITH line, SPLIT(line.LessonDate, '-') AS date
CREATE (lesson:Lesson { name: ToInteger(line.`LessonId`) } )
SET lesson.year = ToInteger(date[0]),
lesson.month = ToInteger(date[1]),
lesson.day = ToInteger(date[2]),
lesson.title = (line.Title),
lesson.abstract = (line.Abstract),
lesson.lesson = (line.Lesson),
lesson.org = (line.MissionDirectorate),
lesson.safety = (line.SafetyIssue),
lesson.url = (line.url)
MERGE (submitter:Submitter { name: toUpper(line.Submitter1) })
MERGE (center:Center { name: toUpper(line.Organization) })
MERGE (topic:Topic { name: ToInteger(line.Topic) })
MERGE (category:Category { name: toUpper(line.Category) })
CREATE (topic)-[:Contains]->(lesson)
CREATE (submitter)-[:Wrote]->(lesson)
CREATE (lesson)-[:OccurredAt]->(center)
CREATE (lesson)-[:InCategory]->(category);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/topicCategory.csv' AS line
MATCH (topic:Topic { name: ToInteger(line.Topic) })
MATCH (category:Category { name: toUpper(line.Category) })
CREATE (topic)-[:AssociatedTo]->(category)
;
// Topic, Correlation.
// Adds a relation to each topic using their correlation
// as a property of the relationship
// Load.
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/topicCorr.csv' AS line
MATCH (topic:Topic), (topic2:Topic)
WHERE topic.name = ToInteger(line.Topic) AND topic2.name = ToInteger(line.ToTopic)
MERGE (topic)-[c:CorrelatedTo {corr : ToFloat(line.Correlation)}]-(topic2)
;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/topicTerms.csv' AS line
MATCH (topic:Topic { name: ToInteger(line.Topic) })
MERGE (term:Term { name: toUpper(line.Terms) })
CREATE (term)-[r:RankIn {rank : ToInteger(line.Rank)}]->(topic)
;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'file:///Users/kevin/Neo4j/doctopics-master/data/topicLabels.csv' AS line
MATCH (topic:Topic { name: ToInteger(line.Topic) })
SET topic.label = line.Label
;
The original Cypher code and data is in David Meza's Repo
I'd just like to get something ready to demo to our company tomorrow morning to 'sell' the 'lessons learned' and usage of a graph database. Any help will be appreciated.
Thanks
Upvotes: 0
Views: 157
Reputation: 5385
did you try
DELETE n,r
on line 3?
Btw purging a store could also be done like this, which is probably faster.
MATCH (n)
DETACH DELETE n
Upvotes: 1