Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-28-2019 08:59 AM
Sorry if this is a silly question! I modelled the following query on something from SO and I just can't see the problem - I have narrowed the issue down to using the nodes from the unwound collection in the MERGE statement as the issue. If I run this:
MATCH (e:EngineFamily {brand:"Norton", name:"Dominator"})-[:HAS_DERIVATIVE]->(d:Derivative)
WITH e, COLLECT (d) AS derivs
UNWIND range(1, size(derivs))AS i
MATCH (c:Component {name:"crankcase"})
WITH derivs[i] AS a1, c
MERGE (a1)-[:HAS_COMPONENT]->(c)
RETURN a1,c
I get: org.neo4j.values.storable.NoValue cannot be cast to org.neo4j.values.virtual.VirtualNodeValue
If I put a dummy node in place of the (a1) node, it works, if I delete the merge altogether it works - so the unwinding and iterating over the "i" value works....
If I use create instead of merge the query just runs and runs.
I used the following from SO as a start point and that seems to use nodes processed in the same way in the MERGE statement.... I have been trying to sort this for hours and fear that either I am missing something obvious or I am just taking the wrong approach altogether...
11-28-2019 09:51 AM
The first I issue I see is range(1, size(derivs))
. You need to use range(0, size(derivs) - 1)
instead.
11-28-2019 09:58 AM
To be honest it's a bit hard to understand what you are trying to do. Why don't you use this:
MATCH (c:Component {name:"crankcase"})
MATCH (e:EngineFamily {brand:"Norton", name:"Dominator"})-[:HAS_DERIVATIVE]->(d:Derivative)
MERGE (d)-[:HAS_COMPONENT]->(c)
I might be missing something but it looks like that you want to connect all Derivatives, that are connected to an EngineFamily, to a Component with name "crankcase".
11-28-2019 10:05 AM
So, now I know - it was something really Dim with a Big "D" - now it works a treat....
11-28-2019 10:07 AM
Thank you so much, I just couldn't see it
All the sessions of the conference are now available online