Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-21-2022 09:25 PM
The following query:
MERGE (resources:Entity {id: '#resources'})
MERGE (dc1:Component {id: 'DocumentChildOf'})
ON MATCH SET dc1.value = '{v1}'
ON CREATE SET dc1.value = '{v1}'
MERGE (dc1)-[:ATTACHED_TO]->(resources)
MERGE (artwork:Entity {id: '#artwork'})
MERGE (dc2:Component {id: 'DocumentChildOf'})
ON MATCH SET dc2.value = '{v2}'
ON CREATE SET dc2.value = '{v2}'
MERGE (dc2)-[:ATTACHED_TO]->(artwork)
Produces the following graph:
My intention was that both #artwork and #resources nodes have a DocumentChildOf node as is shown in the following graph.
Somehow the relationships are matching more broadly than I would think. How can I modify the query to get the desired results?
05-21-2022 09:33 PM
I think I understand what is happening. The following line is matching the DocumentChildOf node created earlier and attaching it to the second entity also.
MERGE (dc2:Component {id: 'DocumentChildOf'})
I'm just not sure how to modify the query to get the desired results.
05-22-2022 06:27 AM
Your understanding is correct.
Your component merges don’t have any identifying properties you are searching on. It looks like you want to create them each time the query is executed. If so, change the ‘merge’ to ‘create’ and just use a ‘set’ for each of the component merges.
All the sessions of the conference are now available online