How to correctly use conditionals like IF or CASE in Cypher query language (Neo4J) to successfully create relationships? -


i failed create relationships in neo4j , encourage has sucessfully done me.

the desired result have detailed visualisation of brother whom, who's mother , on. want extract data single parent-child relationships. means, setting relationship [:relatedto {:how['daughter']}] if node has parent name corresponds field node.name , gender of node f.

i have csv file looks this.

1;jakub hančin;m;1994;4;3 2;hana hančinová;f;1991;4;3 3;alojz hančin jr.;m;1968;15;14 4;viera hančinová;f;1968;9; 5;miroslav barus sr.;m;1965;9; 6;helena barusová;f;1942;; 7;miroslav barus jr.;m;1995;6;5 8;martin barus;m;1991;6;5 9;hedviga barusová;f;1945;; 10;peter hančin jr.;m;1991;12;13 11;zuzka hančinová;f;1996;12;13 12;andrea hančinová;f;1966;; 13;peter hančin sr.;m;1965;15;14 14;alojz hančin sr.;m;1937;; 15;anna hančinová;f;1945;; 

this personal family tree , visualize through neo4j. file created excel, put information table , create database. converted .csv file importable neo4j. have sucessfully installed , @ point of writing cypher script manage it. far, have this:

load csv headers "file:c:/users/skelo/desktop/family database/family database csv utf.txt" row fieldterminator ';' create (n:person) set n = row, n.name = row.name,   n.personid = toint(row.personid) , n.g = row.g,   n.year = toint(row.year), n.parent1 = row.parent1, n.parent2 = row.parent2 n  match(n:person),(b:person) n.parent1 = b.name or n.parent2 = b.name  case b.gender when b.gender = 'f' create (b)-[:isrelatedto{how:['mother']}]->(n) when b.gender = 'm' create (b)-[:isrelatedto{how:['father']}]->(n) return * 

the error message shown looks this.

invalid input 'a': expected 'r/r' (line 11, column 2 (offset: 389)) "case b.gender"   ^ 

somehow, can't figure out why not work. why can't use case command? neo4j not allow me use command create (it expects letter r after c , not a, means create command).

again, want this. have few nodes correctly set. each of nodes (they represent people), want parent1 , parent2 fields , node has same name 1 of these fields. if matches 1 of these, want mark node father or mother previous node (judging gender of node, represents person).

this way fill graph database many relationships, fail @ basic step. please me. if can, please not wrong , why wrong, present solution works.

since want create isrelatedto relationship regardless of gender , property dependent upon conditional, this:

create (b)-[r:isrelatedto]->(n) set r.how = case b.gender when 'f' 'mother' else 'father' end 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -