Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e5fe0ad
Support lang parameter for Konkorde filters
Yoann-Abbes Dec 16, 2020
1314356
fix units tests
Yoann-Abbes Dec 16, 2020
7eb061c
update sdk link doc
Yoann-Abbes Dec 16, 2020
ffcc91e
fix links
Yoann-Abbes Dec 16, 2020
42209ba
fix badges
Yoann-Abbes Dec 18, 2020
1a27b12
Add snippets
Yoann-Abbes Dec 24, 2020
72e1f81
fix
Yoann-Abbes Dec 24, 2020
8691acc
Fix tests
Yoann-Abbes Dec 24, 2020
1434584
Fix commentary
Yoann-Abbes Dec 24, 2020
532558e
Merge branch '7-dev' into support-lang-parameter-for-konkorde-filters
Yoann-Abbes Dec 28, 2020
d3c6fa7
requested changes @rolljee
Yoann-Abbes Dec 28, 2020
565f568
Update doc/7/controllers/auth/search-api-keys/index.md
Yoann-Abbes Dec 29, 2020
451c476
Update doc/7/controllers/auth/search-api-keys/snippets/search-api-key…
Yoann-Abbes Dec 29, 2020
1afb677
Update doc/7/controllers/auth/search-api-keys/snippets/search-api-key…
Yoann-Abbes Dec 29, 2020
4a89ead
Update doc/7/controllers/document/delete-by-query/index.md
Yoann-Abbes Dec 29, 2020
0f8ed67
Update doc/7/controllers/document/search/index.md
Yoann-Abbes Dec 29, 2020
184c86f
Update doc/7/controllers/security/search-users/index.md
Yoann-Abbes Dec 29, 2020
94cc6e6
Update doc/7/controllers/security/search-users/index.md
Yoann-Abbes Dec 29, 2020
45ce532
Update src/controllers/Document.ts
Yoann-Abbes Dec 29, 2020
1b8619e
Update src/controllers/Document.ts
Yoann-Abbes Dec 29, 2020
944cd18
Update doc/7/controllers/document/update-by-query/index.md
Yoann-Abbes Dec 29, 2020
c030418
Update doc/7/controllers/security/search-api-keys/index.md
Yoann-Abbes Dec 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/7/controllers/auth/search-api-keys/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ searchApiKeys([query], [options]);

The search query to apply to API keys content, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

If left empty, the result will return all available API keys of the currently loggued user.

### options
Expand All @@ -40,6 +49,7 @@ Additional query options
| ---------- | ------------------ | ------------ |
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |

## Resolves

Expand Down
11 changes: 11 additions & 0 deletions doc/7/controllers/document/delete-by-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Deletes documents matching the provided search query.

Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

An empty or null query will match all documents in the collection.

<br/>
Expand All @@ -34,6 +43,8 @@ Additional query options
| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- |
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
| `source` | <pre>boolean</pre> | if set to `true` Kuzzle will return each deleted document body in the response |
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |

## Resolves

Expand Down
11 changes: 10 additions & 1 deletion doc/7/controllers/document/search/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ It can lead to memory leaks if a scroll duration too great is provided, or if to
You can restrict the scroll session maximum duration under the `services.storage.maxScrollDuration` configuration key.
:::

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

<br/>

Expand All @@ -50,6 +58,7 @@ Additional query options
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
| `scroll` | <pre>string</pre><br/>(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `30s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#time-units)) |
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |
| `verb` | <pre>string</pre> | (HTTP only) Forces the verb of the route |

#### verb
Expand All @@ -61,7 +70,7 @@ You can set the `verb` option to `GET` to force the SDK to use the GET API inste

### Optional:

- `query`: the search query itself, using the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.
- `query`: the search query itself, using the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) or the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax.
- `aggregations`: control how the search results should be [aggregated](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-aggregations.html)
- `sort`: contains a list of fields, used to [sort search results](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-request-sort.html), in order of importance.

Expand Down
11 changes: 10 additions & 1 deletion doc/7/controllers/document/update-by-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Updates documents matching the provided search query.

Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl.html) syntax.

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

An empty or null query will match all documents in the collection.

<br/>
Expand All @@ -37,7 +46,7 @@ Additional query options.
| ----------------- | ------------------------------- | ---------------------------------------------------------------------------------- |
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
| `source` | <pre>boolean</pre><br/>(`false`)| If true, returns the updated document inside the response

| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |
## Resolves

Returns an object containing 2 arrays: `successes` and `errors`
Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/create-first-admin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Example:

## Resolves

A [`User`](sdk/js/6/core-classes/user/introduction) object containing information about the newly created administrator.
A [`User`](sdk/js/7/core-classes/user/introduction) object containing information about the newly created administrator.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/create-restricted-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Example:

## Resolves

A [`User`](sdk/js/6/core-classes/user/introduction) object containing information about the newly created user.
A [`User`](sdk/js/7/core-classes/user/introduction) object containing information about the newly created user.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/create-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Example:

## Resolves

A [`User`](sdk/js/6/core-classes/user/introduction) object containing information about the newly created user.
A [`User`](sdk/js/7/core-classes/user/introduction) object containing information about the newly created user.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/get-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ getUser(kuid, [options]);

## Resolves

The retrieved [`User`](sdk/js/6/core-classes/user/introduction) object.
The retrieved [`User`](sdk/js/7/core-classes/user/introduction) object.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/replace-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ example:

## Resolves

An [`User`](sdk/js/6/core-classes/user/introduction) object containing information about the updated user.
An [`User`](sdk/js/7/core-classes/user/introduction) object containing information about the updated user.

## Usage

Expand Down
10 changes: 10 additions & 0 deletions doc/7/controllers/security/search-api-keys/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ searchApiKeys(userId, [query], [options]);

The search query to apply to API keys content, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

If left empty, the result will return all available API keys for the user.

### options
Expand All @@ -41,6 +50,7 @@ Additional query options
| ---------- | ------------------ | ------------ |
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |

## Resolves

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/search-profiles/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ searchProfiles([body], [options]);

## Resolves

A [`SearchResult`](sdk/js/6/core-classes/search-result) object containing the retrieved [`Profile`](/sdk/js/7/core-classes/profile) objects.
A [`SearchResult`](sdk/js/7/core-classes/search-result) object containing the retrieved [`Profile`](/sdk/js/7/core-classes/profile) objects.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/search-roles/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ searchRoles([body], [options]);

## Resolves

A [`SearchResult`](sdk/js/6/core-classes/search-result) object containing the retrieved [`Role`](/sdk/js/7/core-classes/role) objects.
A [`SearchResult`](sdk/js/7/core-classes/search-result) object containing the retrieved [`Role`](/sdk/js/7/core-classes/role) objects.

## Usage

Expand Down
14 changes: 12 additions & 2 deletions doc/7/controllers/security/search-users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ searchUsers([query], [options]);

### query

The search query to apply to users content, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.
The search query to apply to users content, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) or the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax.

<SinceBadge version="auto-version"/>

This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
Koncorde filters will be translated into an Elasticsearch query.

::: warning
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
:::

If left empty, the result will return all available users.

Expand All @@ -36,10 +45,11 @@ If left empty, the result will return all available users.
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
| `scroll` | <pre>string</pre><br/>(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `30s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#time-units)) |
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="auto-version"/> |

## Resolves

A [`SearchResult`](sdk/js/6/core-classes/search-result) object containing the retrieved [`User`](/sdk/js/7/core-classes/user) objects.
A [`SearchResult`](sdk/js/7/core-classes/search-result) object containing the retrieved [`User`](/sdk/js/7/core-classes/user) objects.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/update-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Example:

## Resolves

A [`User`](sdk/js/6/core-classes/user/introduction) object containing information about the updated user.
A [`User`](sdk/js/7/core-classes/user/introduction) object containing information about the updated user.

## Usage

Expand Down
3 changes: 2 additions & 1 deletion src/controllers/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class AuthController extends BaseController {
*/
searchApiKeys(
query: JSONObject = {},
options: { from?: number, size?: number } = {}
options: { from?: number, size?: number, lang?: string } = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing parameter documentation in the method description

): Promise<{
/**
* Array of found ApiKeys
Expand All @@ -140,6 +140,7 @@ export class AuthController extends BaseController {
action: 'searchApiKeys',
from: options.from,
size: options.size,
lang: options.lang,
body: query
};

Expand Down
3 changes: 2 additions & 1 deletion src/controllers/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ export class DocumentController extends BaseController {
from?: number;
size?: number;
scroll?: string;
lang?: string;
verb?: string;
} = {}
): Promise<SearchResult<DocumentHit>> {
Expand Down Expand Up @@ -665,7 +666,7 @@ export class DocumentController extends BaseController {
else {
request.body = body;
}
for (const opt of ['from', 'size', 'scroll']) {
for (const opt of ['from', 'size', 'scroll', 'lang']) {
request[opt] = options[opt];
}

Expand Down
3 changes: 2 additions & 1 deletion src/controllers/Security.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class SecurityController extends BaseController {
action: 'searchApiKeys',
from: options.from,
size: options.size,
lang: options.lang,
body: query
};

Expand Down Expand Up @@ -423,7 +424,7 @@ class SecurityController extends BaseController {
body,
action: 'searchUsers'
};
for (const opt of ['from', 'size', 'scroll']) {
for (const opt of ['from', 'size', 'scroll', 'lang']) {
request[opt] = options[opt];
}

Expand Down
9 changes: 6 additions & 3 deletions test/controllers/security.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('Security Controller', () => {
userId: 'kuid',
body: { match: {} },
from: 1,
size: 2
size: 2,
lang: undefined
});

should(result).be.eql({ hits: [1, 2] });
Expand Down Expand Up @@ -1108,7 +1109,8 @@ describe('Security Controller', () => {
body: {foo: 'bar'},
from: undefined,
size: undefined,
scroll: undefined
scroll: undefined,
lang: undefined
}, options);

should(res).be.an.instanceOf(UserSearchResult);
Expand Down Expand Up @@ -1139,7 +1141,8 @@ describe('Security Controller', () => {
body: {foo: 'bar'},
from: 1,
size: 2,
scroll: '10s'
scroll: '10s',
lang: undefined
}, { from: 1, scroll: '10s', size: 2 });

should(res).be.an.instanceOf(UserSearchResult);
Expand Down