searchProfiles #
Searches security profiles.
Available since 7.8.3
Available since Kuzzle 2.14.1
Support for search using a search query with the query property.
This method also supports the Koncorde Filters DSL to match documents by passing the lang argument with the value koncorde.
Koncorde filters will be translated into an Elasticsearch query.
searchProfiles([body], [options]);| Property | Type | Description |
|---|---|---|
body | object | Search query |
options | object | Query options |
body #
| Property | Type | Description |
|---|---|---|
roles | array<string> | Role identifiers Deprecated since 7.8.3 |
query | object | Search query using the ElasticSearch Query DSL or the Koncorde Filters DSL syntax. Available since 7.8.3 |
If the body is left empty, the result will return all available profiles.
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 |
lang | string | Specify the query language to use. By default, it's elasticsearch but koncorde can also be used. |
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) |
timeout | number ( -1) | Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely |
triggerEvents | boolean ( false) | If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop. Available since Kuzzle 2.31.0 |
Resolves #
A SearchResult object containing the retrieved Profile objects.
Usage #
try {
const results = await kuzzle.security.searchProfiles({
query: {
term: { 'policies.roleId': 'default' }
}
});
console.log(results);
/*
ProfileSearchResult { aggregations: undefined,
hits:
[ Profile { _id: 'profile1', policies: [Array] },
Profile { _id: 'profile2', policies: [Array] },
Profile { _id: 'profile3', policies: [Array] },
Profile { _id: 'default', policies: [Array] } ],
fetched: 4,
total: 4 }
*/
console.log(`Successfully retrieved ${results.total} profiles`);
} catch (e) {
console.error(e);
}