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.
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 valuescore
: member score (floating-point number)
Optional: #
ch
(boolean): if true, instead of returning the number of added elements, returns the number of changes performedincr
(boolean): if true, instead of adding elements, increments the existing member with the providedscore
. Only one score-element pair can be specified if this option is setnx
(boolean): if true, only adds new elements, without altering existing onesxx
(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
}
Edit this page on Github(opens new window)