searchUsers
Searches users.
Query Syntax
HTTP
URL: http://kuzzle:7512/users/_search[?from=0][&size=42][&scroll=<time to live>]
Method: POST
Body:
{
"query": {
"bool": {
"must": [
{
"terms": {
"profileIds": ["anonymous", "default"]
}
},
{
"geo_distance": {
"distance": "10km",
"pos": {
"lat": 48.8566140,
"lon": 2.352222
}
}
}
]
}
}
}
Other protocols
{
"controller": "security",
"action": "searchUsers",
"body": {
"query": {
"bool": {
"must": [
{
"in": {
"profileIds": ["anonymous", "default"]
}
},
{
"geo_distance": {
"distance": "10km",
"pos": {
"lat": "48.8566140",
"lon": "2.352222"
}
}
}
]
}
}
},
// optional arguments
"from": 0,
"size": 10,
"scroll": "<time to live>"
}
Arguments
Optional:
from
: the offset from the first result you want to fetch. Usually used with thesize
argumentscroll
: create a new forward-only result cursor. This option must be set with a time duration, at the end of which the cursor is destroyed. If set, a cursor identifier namedscrollId
will be returned in the results. This cursor can then be moved forward using the scrollUsers API actionsize
: the maximum number of users returned in one response page
Body properties
Optional:
The search query itself, using the ElasticSearch Query DSL syntax.
If the body is left empty, the result will return all available users.
Response
Returns an object with the following properties:
hits
: array of object. Each object describes a found user:_id
: user kuid_source
: user definition
total
: total number of users found. Depending on pagination options, this can be greater than the actual number of users in a single result page
{
"status": 200,
"error": null,
"action": "searchUsers",
"controller": "security",
"requestId": "<unique request identifier>",
"result": {
"total": 2,
"hits": [
{
"_id": "kuid1",
"_source": {
// User content
}
},
{
"_id": "kuid2",
"_source" {
// User content
}
}
]
}
}