Delete specific element from array
The FILTER function is deprecated:
https://neo4j.com/docs/cypher-manual/current/functions/list/#functions-filter
They consider using [variable IN list WHERE predicate] instead. You just have to erase the filter() by brackets:
MATCH (n)
WHERE EXISTS(n.some_array)
SET n.array = [x IN n.some_array WHERE x <> "oranges"];
Worked in my case perfectly
Update:
Thanks ANONYMUS for pointing out that "HAS()" is replaced with "EXISTS()"
Sometimes we can get an error in above Query as "Expected exactly one statement per query but got: 2" to remove this we can also use as
match (t:test)
with t,FILTER(x IN t.some_array WHERE x <> "ORANGES") as filterdList
set t.array=filterdList
return t
Cypher doesn't have functions for mutating arrays, but you can create a new array with "oranges"
removed using FILTER
:
MATCH (n)
WHERE HAS(n.some_array)
SET n.array = FILTER(x IN n.some_array WHERE x <> "oranges");