SDK
SDK Javascript v7.x
2

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.


Copied to clipboard!
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)

Resolves #

A SearchResult object containing the retrieved Profile objects.

Usage #

Copied to clipboard!
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);
}