Conditional relationship creation using LOAD CSV in neo4j -
my task import number of friend or follow relationships simple neo4j graph db. input data csv following structure:
owner,friend,type bob,charlie,friend alice,chris,follower
in above example charlie friend of bob , chris follower of alice. want bulk import these neo4j using load csv
i'm having trouble creating conditional relationships during import. import code looks like:
load csv headers "file:./graph.csv" csvline csvline.owner owner, csvline.friend friend, csvline.type type merge (o:person { name: owner }) merge (c:person { name: friend }) merge (u)<-[:is_friend {type: type}]-(c);
i'd rather have 2 types of relationships is_friend
, follows
. when try conditional statements like:
case when type == "friend" merge (u)<-[:is_friend]-(c) else (u)<-[:follows]-(c);
i receive syntax errors on use of case
is there way make conditional relationships during bulk import csv this?
there excellent blog post on @ http://www.markhneedham.com/blog/2014/06/17/neo4j-load-csv-handling-conditionals/.
the trick use foreach on collection build based on conditions.
Comments
Post a Comment