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.

srandmember #

Returns one or more members of a set of unique values, at random.

[Redis documentation]


Query Syntax #

HTTP #

URL: http://kuzzle:7512/ms/_srandmember/<_id>[?count=<count>]
Method: GET

Other protocols #

{
  "controller": "ms",
  "action": "srandmember",
  "_id": "<key>",
  // optional
  "count": "<count>"
}

Arguments #

  • _id: set key identifier

Optional: #

  • count: return count members, at random (default: 1). If positive, then returned values are unique. If negative, a set member can be returned multiple times.

Response #

If count is not set or equal to 1, returns the member as a string:

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

If the absolute count value is greater than 1, then an array of random members is returned instead:

{
  "requestId": "<unique request identifier>",
  "status": 200,
  "error": null,
  "controller": "ms",
  "action": "srandmember",
  "collection": null,
  "index": null,
  "result": [
    "random member 1",
    "random member 2",
    "..."
  ]
}