redisredisjson

JSON.DEL applied to an array with filter on its elements returns no more than 10 elements


I have this json document $.workspace.localIndex[] where array elements have this schema

{
    "propertyName": "the-name",
    "referencedItem": "e2e34852-0577-4fc1-9eb8-e68acd2a548c",
    "hit": 1,
    "ID": "5fdca267-0fbd-4b30-80cb-748133d58b01",
    "ownerId": "7416f9ed-d165-4817-ad0e-9caa259ad0ff"
}

a call to
JSON.DEL mf/application/workspace-manager/workspace(IVA74BIS:04.00.00-0) "$.workspace.localIndex[?(@.ownerId == '<value>')]"
delete no more than 10 elements every time.
Is this the desidered behaviour? Am I missing something?

JSON.DEL test2
JSON.SET test2 "$" '{"localIndex":[]}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "1"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "14"}'
JSON.ARRAPPEND test2 "$.localIndex" '{"index": "15"}'
JSON.DEL test2 "$.localIndex[?(@.index == '1')]"
JSON.GET test2 "$.localIndex[?(@.index == '1')]"

Last JSON.DEL returns 10 as result and next JSON.GET returns an array with 3 elements where the expectation is an empty one.


Solution

  • Thank you for reporting this. Issue is confirmed:

    > JSON.SET j $ '[{"x":1,"y":1},{"x":2,"y":1},{"x":3,"y":1},{"x":4,"y":1},{"x":5,"y":1},{"x":6,"y":1},{"x":7,"y":1},{"x":8,"y":1},{"x":9,"y":1},{"x":10,"y":1},{"x":11,"y":1},{"x":12,"y":1}]' 
    OK
    > JSON.DEL j '$[?(@.y==1)]'
    (integer) 10
    > JSON.GET j 
    "[{\"x\":11,\"y\":1},{\"x\":12,\"y\":1}]"
    

    A simpler example:

    > JSON.SET j $ '[{"x":1},{"x":2},{"x":3},{"x":4},{"x":5},{"x":6},{"x":7},{"x":8},{"x":9},{"x":10},{"x":11},{"x":12}]' 
    OK
    > JSON.DEL j '$[?(@.x>0)]'
    (integer) 10
    > JSON.GET j 
    "[{\"x\":11},{\"x\":12}]"