searchUsers #
Return users matching the given filter.
searchUsers(filters, [options], callback) #
Arguments | Type | Description |
---|---|---|
filters | JSON Object | Filter in Elasticsearch's Query DSL format |
options | JSON Object | Optional parameters |
callback | function | Callback handling the response |
Options #
Option | Type | Description | Default |
---|---|---|---|
from | number | Starting offset | 0 |
queuable | boolean | Make this request queuable or not | true |
scroll | string | Start a scroll session, with a time to live equals to this parameter's value following the Elastisearch time format | undefined |
size | number | Number of hits to return per result page | 10 |
To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search).
Callback Response #
Return a JSON Object
Usage #
const filter = {
bool: {
must: [
{
terms: {
profileIds: ['anonymous', 'default']
}
},
{
geo_distance: {
distance: '10km',
pos: {
lat: 48.8566140,
lon: 2.352222
}
}
}
]
}
};
// optional: result pagination configuration
const options = {
from: 0,
size: 10,
scroll: '1m'
};
// Using callbacks (NodeJS or Web Browser)
kuzzle
.security
.searchUsers(filters, options, function(error, result) {
// result is a JSON Object with the following properties:
// {
// total: <number of found users>,
// users: [<User object>, <User object>, ...],
// scrollId: "<only if a 'scroll' parameter has been passed in the options>"
// }
});
// Using promises (NodeJS)
kuzzle
.security
.searchUsersPromise(filters, options)
.then(result => {
// result is a JSON Object with the following properties:
// {
// total: <number of found users>,
// users: [<User object>, <User object>, ...],
// scrollId: "<only if a 'scroll' parameter has been passed in the options>"
// }
});
Callback response:
{
"total": 124,
"users": [
// array of User objects
],
// only if a scroll parameter has been provided
"scrollId": "<scroll identifier>"
}
Edit this page on Github(opens new window)