Search code examples
rediscypherredisgraph

How to remove an element from an array in redisgraph


How to remove an element from an array in redisgraph

Consider the below data in the redisgraph database.

graph.query Test "MATCH (u:Person) Create (:Person {address:['something1', 'something2']})"

I need to remove something1 from the address list.

How can we achieve by writing a cypher query in redisgraph database?


Solution

  • Consider the following query, it will remove element at position 4 (0 base indexing)

    127.0.0.1:6379> GRAPH.QUERY g "WITH [1,2,3,4,5,6,7,8,9,10] AS arr RETURN arr[..4] + arr[5..]"
    1) 1) arr[..4] + arr[5..]
    2) 1) 1) "[1, 2, 3, 4, 6, 7, 8, 9, 10]"