Run this to get a list of all internal Ids for all nodes with label
match(a:itemA) with collect(id(a)) as IdList merge (c:cache) set c.IdList = IdList
Then run this to try and retrieve all nodes with label
itemA, whose internal Id is in the list you previously stored:
match (c:cache) with c.IdList as IdList match (a:itemA) where id(a) in IdList return count(a)
Observe Neo explode because it can't convert
org.neo4j.values.storable.LongArray (the array you stored in the node with label
org.neo4j.values.virtual.ListValue (the list in memory). Both of these lists were generated using the
Id() function. Any ideas how to resolve this error? Do we need to run a cast somewhere?
Thanks @Cobra . Although this does get around the type casting issue, it performs even worse than the previous solution we were using. For reference, we're currently using
UNWIND on the stored list then
COLLECT on the result, but the
UNWIND operation is pretty slow (circa 30 seconds over 0.5million nodes). With the
toInteger solution you suggested, 50 nodes takes about 1 second and 0.5million nodes takes hours.