JSON.NUMMULTBY - Amazon ElastiCache (Redis OSS)
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

JSON.NUMMULTBY

Multiplies the number values at the path by a given number.

Syntax

JSON.NUMMULTBY <key> <path> <number>
  • key (required) – A Redis OSS key of JSON document type.

  • path (required) – A JSON path.

  • number (required) – A number.

Return

If the path is enhanced syntax:

  • Array of bulk strings that represent the resulting value at each path.

  • If a value is not a number, its corresponding return value is null.

  • WRONGTYPE error if the number cannot be parsed.

  • OVERFLOW error if the result is out of the range of a 64-bit IEEE double precision floating point number.

  • NONEXISTENT if the document key does not exist.

If the path is restricted syntax:

  • Bulk string that represents the resulting value.

  • If multiple values are selected, the command returns the result of the last updated value.

  • WRONGTYPE error if the value at the path is not a number.

  • WRONGTYPE error if the number cannot be parsed.

  • OVERFLOW error if the result is out of the range of a 64-bit IEEE double.

  • NONEXISTENT if the document key does not exist.

Examples

Enhanced path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMMULTBY k1 $.d[*] 2 "[2,4,6]" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[1],\"c\":[1,2],\"d\":[2,4,6]}" 127.0.0.1:6379> JSON.SET k1 $ '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMMULTBY k1 $.a[*] 2 "[]" 127.0.0.1:6379> JSON.NUMMULTBY k1 $.b[*] 2 "[2]" 127.0.0.1:6379> JSON.NUMMULTBY k1 $.c[*] 2 "[2,4]" 127.0.0.1:6379> JSON.NUMMULTBY k1 $.d[*] 2 "[2,4,6]" 127.0.0.1:6379> JSON.SET k2 $ '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}}' OK 127.0.0.1:6379> JSON.NUMMULTBY k2 $.a.* 2 "[]" 127.0.0.1:6379> JSON.NUMMULTBY k2 $.b.* 2 "[2]" 127.0.0.1:6379> JSON.NUMMULTBY k2 $.c.* 2 "[2,4]" 127.0.0.1:6379> JSON.NUMMULTBY k2 $.d.* 2 "[2,4,6]" 127.0.0.1:6379> JSON.SET k3 $ '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"b"}, "d":{"a":1, "b":"b", "c":3}}' OK 127.0.0.1:6379> JSON.NUMMULTBY k3 $.a.* 2 "[null]" 127.0.0.1:6379> JSON.NUMMULTBY k3 $.b.* 2 "[null,2]" 127.0.0.1:6379> JSON.NUMMULTBY k3 $.c.* 2 "[null,null]" 127.0.0.1:6379> JSON.NUMMULTBY k3 $.d.* 2 "[2,null,6]"

Restricted path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMMULTBY k1 .d[1] 2 "4" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[1],\"c\":[1,2],\"d\":[1,4,3]}" 127.0.0.1:6379> JSON.SET k1 . '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}' OK 127.0.0.1:6379> JSON.NUMMULTBY k1 .a[*] 2 (error) NONEXISTENT JSON path does not exist 127.0.0.1:6379> JSON.NUMMULTBY k1 .b[*] 2 "2" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[1,2],\"d\":[1,2,3]}" 127.0.0.1:6379> JSON.NUMMULTBY k1 .c[*] 2 "4" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[2,4],\"d\":[1,2,3]}" 127.0.0.1:6379> JSON.NUMMULTBY k1 .d[*] 2 "6" 127.0.0.1:6379> JSON.GET k1 "{\"a\":[],\"b\":[2],\"c\":[2,4],\"d\":[2,4,6]}" 127.0.0.1:6379> JSON.SET k2 . '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}}' OK 127.0.0.1:6379> JSON.NUMMULTBY k2 .a.* 2 (error) NONEXISTENT JSON path does not exist 127.0.0.1:6379> JSON.NUMMULTBY k2 .b.* 2 "2" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":1,\"b\":2},\"d\":{\"a\":1,\"b\":2,\"c\":3}}" 127.0.0.1:6379> JSON.NUMMULTBY k2 .c.* 2 "4" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":2,\"b\":4},\"d\":{\"a\":1,\"b\":2,\"c\":3}}" 127.0.0.1:6379> JSON.NUMMULTBY k2 .d.* 2 "6" 127.0.0.1:6379> JSON.GET k2 "{\"a\":{},\"b\":{\"a\":2},\"c\":{\"a\":2,\"b\":4},\"d\":{\"a\":2,\"b\":4,\"c\":6}}" 127.0.0.1:6379> JSON.SET k3 . '{"a":{"a":"a"}, "b":{"a":"a", "b":1}, "c":{"a":"a", "b":"b"}, "d":{"a":1, "b":"b", "c":3}}' OK 127.0.0.1:6379> JSON.NUMMULTBY k3 .a.* 2 (error) WRONGTYPE JSON element is not a number 127.0.0.1:6379> JSON.NUMMULTBY k3 .b.* 2 "2" 127.0.0.1:6379> JSON.GET k3 "{\"a\":{\"a\":\"a\"},\"b\":{\"a\":\"a\",\"b\":2},\"c\":{\"a\":\"a\",\"b\":\"b\"},\"d\":{\"a\":1,\"b\":\"b\",\"c\":3}}" 127.0.0.1:6379> JSON.NUMMULTBY k3 .c.* 2 (error) WRONGTYPE JSON element is not a number 127.0.0.1:6379> JSON.NUMMULTBY k3 .d.* 2 "6" 127.0.0.1:6379> JSON.GET k3 "{\"a\":{\"a\":\"a\"},\"b\":{\"a\":\"a\",\"b\":2},\"c\":{\"a\":\"a\",\"b\":\"b\"},\"d\":{\"a\":2,\"b\":\"b\",\"c\":6}}"