Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-21-2021 10:20 PM
This works fine:
merge (s:subject{name:sub})
merge (o:object{name:obj})
merge (s)-[:pre]->(o)
however, I want change relationship between s and o by another like this:
load csv with headers
from 'file:///knowledge_triple.csv'
as line
with line.Subject as sub, line.Predicate as pre, line.Object as obj
merge (s:subject{name:sub})
merge (o:object{name:obj})
merge (s)-[pre]->(o)
this cannot be correct, I wonder if it's possiable. 3q
01-22-2021 12:00 AM
Try this:
CALL apoc.create.relationship(s, pre,{}, o) YIELD rel
REMOVE rel.noOp
// REMOVE rel.noOp is a dummy script as we have to have a return value.
01-22-2021 09:18 AM
I'm not clear what your question is, but I do believe you have a typo. There is a missing colon before the label pre
merge (s)-[pre]->(o)
should
merge (s)-[:pre]->(o)
I do recommend the style guide of using all uppercase for Labels as it makes it easier to detect see these errors:
merge (s)-[:PRE]->(o)
02-01-2021 08:14 PM
In this particular case, I think what they were asking for was a way to create the type of the relationship dynamically (from a variable, parameter, or other derived value), so the lack of the colon for the type was intended here (though good eyes, these typos are common).
And dynamic relationship type isn't supported in Cypher (nor is dynamic node labeling), so APOC procs would be the workaround, as ameyasoft provided.
All the sessions of the conference are now available online