Hi,
Yeah something seems to happen during your ,COLLECT([type(tu),tv.version]) AS tus so it seems.
The general filter function works with the comparision, like this one:
MATCH (tt)<-[tu:ADD|REMOVE]-(tv:tocversion)
WITH tt,tu,tv
ORDER BY tt.id,tv.version DESC
WITH tt,type(tu) AS Rel,collect(tv) AS tus
RETURN tt.id,[x IN tus
WHERE x.version>2 | x] AS filtered,Rel
So, Is it mandatory for you to have the output exactly like you had it? Otheriwse these works similar
MATCH (tt)<-[tu:ADD|REMOVE]-(tv:tocversion)
WITH tt,tu,tv
ORDER BY tt.id,tv.version DESC
WITH tt,type(tu) AS Rel,collect(tv) AS tus
RETURN tt.id,[x IN tus
WHERE x.version>2 | x] AS filtered,Rel
MATCH (tt)<-[tu:ADD|REMOVE]-(tv:tocversion)
WITH tt,tu,tv
ORDER BY tt.id,tv.version DESC
WITH tt,type(tu) AS Rel,collect(tv) AS tus
RETURN tt.id,collect([filter(x IN tus
WHERE x.version>2), Rel]) AS filtered
or more similar your original output
MATCH (tt)<-[tu:ADD|REMOVE]-(tv:tocversion)
WITH tt,tu,tv
ORDER BY tt.id,tv.version DESC
WITH tt,type(tu) AS Rel,collect(tv) AS tus
RETURN tt.id,collect([[x IN tus
WHERE x.version>2 | x.version], Rel]) AS filtered