Hi,
I'm trying to create virtual nodes and set properties on some of them if they're not null. The virtual node property creation is being done using list comprehension as I have to collect a bunch of nodes to make into virtual ones, dependent on the value of a property in the original node. There can't be any nulls as I have to create relationships between them, and neo4j does not handle nulls. Is there a way around this? The code I have so far is below:
MATCH (m)-[x]->(n)
WHERE m.date_live > date({year:2020, month:6})
AND m.date_decommissioned < date({year:2024, month:6})
AND n.date_live > date({year:2020, month:6})
AND n.date_decommissioned < date({year:2024, month:6})
WITH COLLECT(DISTINCT m.name) AS sources,
COLLECT(DISTINCT n.name) AS targets, m
WITH [source IN sources | apoc.create.vNode(['Source'],{name:source, data_sent:split(m.data_sent, ",")})] AS sourcenodes,
[target IN targets | apoc.create.vNode(['Target'],{name:target})] AS targetnodes
WITH apoc.map.groupBy(sourcenodes, 'name') AS vsource,
apoc.map.groupBy(targetnodes, 'name') AS vtarget
MATCH (m)-[x]->(n)
WITH vsource, vtarget, m, x, n
WHERE m.date_live > date({year:2020, month:6})
AND m.date_decommissioned < date({year:2024, month:6})
AND n.date_live > date({year:2020, month:6})
AND n.date_decommissioned < date({year:2024, month:6})
return vsource,
vtarget
The nodes are collected and made into virtual ones dependent on if their live and decommission dates are within the boundaries set. I want to make sure that the data_sent property is either the list of data sent, or not set at all, rather than being the list or a null, as I want relationships between source and target.
Otherwise, is there a way to iteratively copy the entire original node (so name, data_sent, and all the other properties listed in it) so that it won't create categories that don't exist in the original?
Thanks in advance!