In Neo4j graph I have 2 nodes with same label and 4 properties, I want the condition to check value of there properties are equal, and if any of 4 properties are equal I want to create relation between those 2 nodes as Similar_To , this relation should also contain property as percentage , depend on out of 4 properties of nodes how many properties are matching we are calculating percentage (If 1 value for 1 property matching then percentage is 25 ,if 2 then percentage is 50 if 3 then 75 and if 4 then 100) Want query for this ,Can I have 4 if conditions in my cypher query and How I can write it,Please reply
I tried
MATCH(n:Student),(m:Student)
WHERE id(n<>id(m) and (n.age=m.age OR n.marks=m.marks OR n.div=m.div OR n.weight=m.weight)
CREATE (n)-[:SIMILAR_TO{Percentage:25}]->(m) RETURN n,m
Will create relationship if value for any of 4 properties are equal, but percentage is always 25, I want percentage value depend on number of properties matching
Trying something like
WITH 0 as x
MATCH(n:Student),(m:Student)
WHERE id(n)<>id(m)
//If n.age=m.age then x=x+25
//If n.marks=m.marks then x=x+25
//If n.div=m.div then x=x+25
//If n.weight=m.weight then x=x+25
if x<>0 then CREATE (n)-[:SIMILAR_TO{Percentage:x}]->(m)
RETURN n,m
But I don't know How to write those 4 If conditions