searchUsers #
Searches users.
searchUsers([query], [options]);
Property | Type | Description |
---|---|---|
query | object | Search query |
options | object | Query options |
query #
The search query to apply to users content, using ElasticSearch Query DSL syntax.
If left empty, the result will return all available users.
options #
Property | Type (default) | Description |
---|---|---|
queuable | boolean ( true ) | If true, queues the request during downtime, until connected to Kuzzle again |
from | number ( 0 ) | Offset of the first document to fetch |
size | number ( 10 ) | Maximum number of documents to retrieve per page |
scroll | string ( "" ) | When set, gets a forward-only cursor having its ttl set to the given value (ie 30s ; cf elasticsearch time limits) |
Resolves #
A SearchResult
object containing the retrieved User
objects.
Usage #
try {
const results = await kuzzle.security.searchUsers({
term: {
status: 'student'
}
});
console.log(results);
/*
UserSearchResult {
aggregations: undefined,
hits:
[ User { _kuzzle: [Kuzzle], _id: 'user2', content: [Object] },
User { _kuzzle: [Kuzzle], _id: 'user1', content: [Object] },
User { _kuzzle: [Kuzzle], _id: 'user3', content: [Object] } ],
fetched: 3,
total: 3 }
*/
console.log(`Successfully retrieved ${results.total} users`);
} catch (e) {
console.error(e);
}
Edit this page on Github(opens new window)