Core
API v2.x
2

zrevrangebyscore #

Identical to zrangebyscore, except that the sorted set is traversed in descending order.

[Redis documentation]


Query Syntax #

HTTP #

URL: http://kuzzle:7512/ms/_zrevrangebyscore/<_id>?min=<min interval>&max=<max interval>[&limit=offset,count][&options=withscores]
Method: GET

Other protocols #

{
  "controller": "ms",
  "action": "zrevrangebyscore",
  "_id": "<key>",
  "min": "<min interval>",
  "max": "<max interval>",
  // optional
  "limit": ["<offset>", "<count>"],
  "options": ["withscores"]
}

Arguments: #

  • _id: sorted set identifier
  • min: minimum score
  • max: maximum score

By default, min and max are inclusive. Check the full Redis documentation for other options.

Optional: #

  • limit: an array of 2 integers, used to limit the number of returned matching elements (similar to SELECT LIMIT offset, count in SQL). Format: [<offset>,<count>]
  • withscores: return the score alongside the found elements

Response #

By default, returns the list of elements in the provided score range:

{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "zrevrangebyscore",
  "collection": null,
  "index": null,
  "result": [
    "...",
    "element2",
    "element1"
  ]
}

If the withscores option is provided, then the returned array alternates elements with their score:

{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "zrevrangebyscore",
  "collection": null,
  "index": null,
  "result": [
    "...",
    "element2",
    "score of element2",
    "element1",
    "score of element1"
  ]
}