Core
API v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

zadd #

Adds elements to a sorted set.

If the key does not exist, it is created, holding an empty sorted set.

If the key already exists but does not hold a sorted set, an error is returned.

If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set.

[Redis documentation]


Query Syntax #

HTTP #

URL: http://kuzzle:7512/ms/_zadd/<_id>
Method: POST
Body:
{
  "elements": [
    {"score": "<score1>", "member": "<value1>"},
    {"score": "<score2>", "member": "<value2>"},
    {"score": "<...>", "member": "<...>"}
  ]
}

Other protocols #

{
  "controller": "ms",
  "action": "zadd",
  "_id": "<key>",
  "body": {
    "elements": [
      {"score": "<score1>", "member": "<value1>"},
      {"score": "<score2>", "member": "<value2>"},
      {"score": "<...>", "member": "<...>"}
    ]
  }
}

Arguments #

  • _id: sorted set identifier

Body properties #

  • elements: an array of objects. Each object describes a sorted set member, using the following properties:
    • member: member value
    • score: member score (floating-point number)

Optional: #

  • ch (boolean): if true, instead of returning the number of added elements, returns the number of changes performed
  • incr (boolean): if true, instead of adding elements, increments the existing member with the provided score. Only one score-element pair can be specified if this option is set
  • nx (boolean): if true, only adds new elements, without altering existing ones
  • xx (boolean): if true, ignores new elements, alters only existing ones

Response #

Returns the number of added elements.

{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "zadd",
  "collection": null,
  "index": null,
  "result": 6
}