Skip to content

Commit ee8ab63

Browse files
authored
Improve document search doc (#678)
1 parent 9fa82fd commit ee8ab63

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

doc/7/controllers/document/search/index.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,21 @@ Searches documents.
1212
There is a limit to how many documents can be returned by a single search query.
1313
That limit is by default set at 10000 documents, and you can't get over it even with the from and size pagination options.
1414

15+
Once a `SearchResult` has been retrieved, navigation through pages can be done with the [SearchResult.next](/sdk/js/7/core-classes/search-result/next) method.
16+
1517
:::info
1618
When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/7/core-classes/search-result/next) rather than increasing the size parameter.
1719
:::
1820

1921
::: warning
20-
When using a cursor with the `scroll` option, Elasticsearch has to duplicate the transaction log to keep the same result during the entire scroll session.
21-
It can lead to memory leaks if a scroll duration too great is provided, or if too many scroll sessions are open simultaneously.
22-
:::
23-
24-
::: info
25-
<SinceBadge version="Kuzzle 2.2.0"/>
26-
You can restrict the scroll session maximum duration under the `services.storage.maxScrollDuration` configuration key.
22+
When using a cursor with the `scroll` option, Elasticsearch duplicates the transaction log to keep the same result during the entire scroll session.
23+
It can lead to memory leaks if a scroll duration too great is provided, or if too many scroll sessions are open simultaneously.
2724
:::
2825

2926
<SinceBadge version="7.4.8"/>
3027

31-
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`.
32-
Koncorde filters will be translated into an Elasticsearch query.
33-
34-
::: warning
35-
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
36-
:::
28+
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`.
29+
Koncorde filters will be translated into an Elasticsearch query.
3730

3831
<br/>
3932

@@ -79,14 +72,38 @@ An empty body matches all documents in the queried collection.
7972

8073
## Resolves
8174

82-
Resolves to a [SearchResult](/sdk/js/7/core-classes/search-result) object.
75+
Resolves to a [SearchResult](/sdk/js/7/core-classes/search-result/properties) object.
8376

8477
## Usage
8578

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

81+
<details><summary>Show snippet</summary>
82+
8883
<<< ./snippets/search-es.js
8984

85+
</details>
86+
9087
With the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax.
9188

89+
<details><summary>Show snippet</summary>
90+
9291
<<< ./snippets/search-koncorde.js
92+
93+
</details>
94+
95+
Pagination with [SearchResult.next](/sdk/js/7/core-classes/search-result/next)
96+
97+
<details><summary>Show snippet</summary>
98+
99+
```js
100+
let result = await sdk.document.search('nyc-open-data', 'yellow-taxi', {}, { scroll: '2s' });
101+
102+
while (result) {
103+
// process result.hits here
104+
105+
result = await result.next();
106+
}
107+
```
108+
109+
</details>

doc/7/essentials/realtime-application/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ They are automatically connected to the realtime engine, and their content (`_so
2929

3030
You can therefor directly use them as props for your frontend components for example.
3131

32-
::: warn
32+
::: warning
3333
There is a limit on how many realtime documents a single observer instance can manage. This limit is set by collection and by default it's 100 documents per collection. You can increase this limit in Kuzzle configuration under the `limits.subscriptionConditionsCount` key.
3434
:::
3535

0 commit comments

Comments
 (0)