Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-29-2019 01:49 PM
Hello,
I want to MERGE
a node:
MERGE (a: Article {URL: event.URL})
If the node does not exist, I need to do this:
ON CREATE FOREACH( site_name in CASE WHEN event.site_name is not null then [1] ELSE [] END |
MERGE (w: Website { value: event.site_name})
MERGE (w)-[:PUBLISHED]->(a))
// all of the tag creation
FOREACH( tag in CASE WHEN event.tags is not NULL then event.tags else [] END |
Merge (t: Article_Tag {value: tag})
CREATE (a)-[: HAS_ARICLE_TAG {date:event_datetime}]->(t))
I believe that ON CREATE
only works with SET
, but as above, i need to execute multiple statements.
I have tried ON CREATE FOREACH(ignoreme in case when event.article is not null then [1] else [] end |...\\ multiple statements)
but this does not escape the SET problem.
Is there a way to create multiple nodes and relationships with an ON CREATE
clause?
Solved! Go to Solution.
09-30-2019 03:01 AM
Keep in mind that nothing will happen if the MATCH fails to find anything, as there will be no rows at all for the FOREACH to execute upon. If you need that, then use OPTIONAL MATCH instead, which will result in a
being null if no match is found.
09-29-2019 02:34 PM
solved with
MATCH (a: Article {URL: event.URL})
FOREACH(ignoreme in case when a is null then [1] else [] end | .....statements...)
09-30-2019 03:01 AM
Keep in mind that nothing will happen if the MATCH fails to find anything, as there will be no rows at all for the FOREACH to execute upon. If you need that, then use OPTIONAL MATCH instead, which will result in a
being null if no match is found.
09-30-2019 03:35 AM
ah actually this is important, and there is a typo in my solution, I was looking for exactly what you are suggesting, I will correct now.
Thank you Andrew!
All the sessions of the conference are now available online