Core
API v2.x
2

zrange #

Returns elements depending on their position in the sorted set.

[Redis documentation]


Query Syntax #

HTTP #

Copied to clipboard!
URL: http://kuzzle:7512/ms/_zrange/<_id>?start=<index start>&stop=<index stop>[&options=withscores]
Method: GET

Other protocols #

Copied to clipboard!
{
  "controller": "ms",
  "action": "zrange",
  "_id": "<key>",
  "start": <index start>,
  "stop": <index stop>,
  // optional
  "options": ["withscores"]
}

Arguments #

  • _id: sorted set identifier
  • start: starting position index, inclusive
  • stop: ending position index, inclusive

Optional: #

  • withscores: return the score alongside the found elements

Response #

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

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

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

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