Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-08-2021 09:27 AM
Run this to get a list of all internal Ids for all nodes with label itemA
:
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 cache
) to 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?
10-08-2021 12:43 PM
Hello @sporritt and welcome to the Neo4j community
Yes, you can use the toInteger() function:
MATCH (c:cache)
WITH c.IdList AS IdList
MATCH (a:itemA)
WHERE toInteger(id(a)) IN IdList
RETURN count(a)
Regards,
Cobra
10-11-2021 07:14 AM
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.
10-11-2021 01:14 PM
One thing you can try is to use apoc.coll.partition to split IdList into small chunks like,
apoc.coll.partition(IdList, 2500) and save each partition as a separate property of (c:cache) node.
All the sessions of the conference are now available online