Skip to content

Commit e8dc747

Browse files
authored
Merge serverless functionality from @elastic/elasticsearch-serverless (#2695)
* Expose a serverMode option to enable serverless-friendly defaults * Update basic config docs to note how the serverMode flag works * Docs cleanup * Add another note to docs about connecting to serverless
1 parent c5f9625 commit e8dc747

File tree

6 files changed

+173
-99
lines changed

6 files changed

+173
-99
lines changed

docs/reference/basic-config.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ const client = new Client({
2020

2121
### `node` or `nodes`
2222

23-
The Elasticsearch endpoint to use. It can be a single string or an array of strings:
23+
The {{es}} endpoint to use. It can be a single string or an array of strings:
2424

2525
```js
2626
node: 'http://localhost:9200'
2727
```
2828

29+
```js
30+
nodes: ['http://localhost:9200', 'http://localhost:9201']
31+
```
32+
2933
Or it can be an object (or an array of objects) that represents the node:
3034

3135
```js
@@ -52,7 +56,6 @@ Default: `null`
5256

5357
Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).
5458
See [Authentication](/reference/connecting.md#authentication) for more details.
55-
5659

5760
Basic authentication:
5861

@@ -113,7 +116,7 @@ Max ping request timeout in milliseconds for each request.
113116
Type: `number, boolean`<br>
114117
Default: `false`
115118

116-
Perform a sniff operation every `n` milliseconds.
119+
Perform a sniff operation every `n` milliseconds.
117120

118121
:::{tip}
119122
Sniffing might not be the best solution. Before using the various `sniff` options, review this [blog post](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how).
@@ -182,7 +185,7 @@ Options: `'gzip'`, `false`
182185
Type: `http.SecureContextOptions`<br>
183186
Default: `null`
184187

185-
The [tls configuraton](https://nodejs.org/api/tls.md).
188+
The [tls configuraton](https://nodejs.org/api/tls.html).
186189

187190
---
188191

@@ -192,7 +195,6 @@ Type: `string, URL`<br>
192195
Default: `null`
193196

194197
If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.
195-
196198

197199
```js
198200
const client = new Client({
@@ -213,7 +215,7 @@ const client = new Client({
213215
Type: `http.AgentOptions, function`<br>
214216
Default: `null`
215217

216-
http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.
218+
http agent [options](https://nodejs.org/api/http.html#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.
217219

218220
```js
219221
const client = new Client({
@@ -394,4 +396,26 @@ When configured, `maxResponseSize` verifies that the uncompressed response size
394396
Type: `number`<br>
395397
Default: `null`
396398

397-
When configured, `maxCompressedResponseSize` verifies that the compressed response size is lower than the configured number. If it’s higher, the request will be canceled. The `maxCompressedResponseSize` cannot be higher than the value of `buffer.constants.MAX_STRING_LENGTH`.
399+
When configured, `maxCompressedResponseSize` verifies that the compressed response size is lower than the configured number. If it’s higher, the request will be canceled. The `maxCompressedResponseSize` cannot be higher than the value of `buffer.constants.MAX_STRING_LENGTH`.
400+
401+
---
402+
403+
### `redaction`
404+
405+
Type: `object`<br>
406+
Default: A configuration that will replace known sources of sensitive data in `Error` metadata
407+
408+
Options for how to redact potentially sensitive data from metadata attached to `Error` objects
409+
410+
::::{note}
411+
[Read about redaction](/reference/advanced-config.md#redaction) for more details
412+
::::
413+
414+
---
415+
416+
### `serverMode`
417+
418+
Type: `string`<br>
419+
Default: `"stack"`
420+
421+
Setting to `"stack"` sets defaults assuming a traditional (non-serverless) {{es}} instance. Setting to `"serverless"` sets defaults to work more seamlessly with [Elastic Cloud Serverless](https://www.elastic.co/guide/en/serverless/current/intro.html), like enabling compression and disabling features that assume the possibility of multiple {{es}} nodes.

docs/reference/client-helpers.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ The client comes with an handy collection of helpers to give you a more comforta
1111
The client helpers are experimental, and the API may change in the next minor releases. The helpers will not work in any Node.js version lower than 10.
1212
::::
1313

14-
15-
1614
## Bulk helper [bulk-helper]
1715

1816
Added in `v7.7.0`
1917

2018
Running bulk requests can be complex due to the shape of the API, this helper aims to provide a nicer developer experience around the Bulk API.
2119

22-
2320
### Usage [_usage_3]
2421

2522
```js
@@ -67,10 +64,8 @@ To create a new instance of the Bulk helper, access it as shown in the example a
6764
| `wait` | How much time to wait before retries in milliseconds.<br> *Default:* 5000.<br><br>```js<br>const b = client.helpers.bulk({<br> wait: 3000<br>})<br>```<br> |
6865
| `refreshOnCompletion` | If `true`, at the end of the bulk operation it runs a refresh on all indices or on the specified indices.<br> *Default:* false.<br><br>```js<br>const b = client.helpers.bulk({<br> refreshOnCompletion: true<br> // or<br> refreshOnCompletion: 'index-name'<br>})<br>```<br> |
6966

70-
7167
### Supported operations [_supported_operations]
7268

73-
7469
#### Index [_index_2]
7570

7671
```js
@@ -84,7 +79,6 @@ client.helpers.bulk({
8479
})
8580
```
8681

87-
8882
#### Create [_create_4]
8983

9084
```js
@@ -98,7 +92,6 @@ client.helpers.bulk({
9892
})
9993
```
10094

101-
10295
#### Update [_update_3]
10396

10497
```js
@@ -116,7 +109,6 @@ client.helpers.bulk({
116109
})
117110
```
118111

119-
120112
#### Delete [_delete_10]
121113

122114
```js
@@ -130,7 +122,6 @@ client.helpers.bulk({
130122
})
131123
```
132124

133-
134125
### Abort a bulk operation [_abort_a_bulk_operation]
135126

136127
If needed, you can abort a bulk operation at any time. The bulk helper returns a [thenable](https://promisesaplus.com/), which has an `abort` method.
@@ -139,7 +130,6 @@ If needed, you can abort a bulk operation at any time. The bulk helper returns a
139130
The abort method stops the execution of the bulk operation, but if you are using a concurrency higher than one, the operations that are already running will not be stopped.
140131
::::
141132

142-
143133
```js
144134
const { createReadStream } = require('fs')
145135
const split = require('split2')
@@ -164,7 +154,6 @@ const b = client.helpers.bulk({
164154
console.log(await b)
165155
```
166156

167-
168157
### Passing custom options to the Bulk API [_passing_custom_options_to_the_bulk_api]
169158

170159
You can pass any option supported by the link: [Bulk API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk) to the helper, and the helper uses those options in conjunction with the Bulk API call.
@@ -181,7 +170,6 @@ const result = await client.helpers.bulk({
181170
})
182171
```
183172

184-
185173
### Usage with an async generator [_usage_with_an_async_generator]
186174

187175
```js
@@ -214,7 +202,6 @@ const result = await client.helpers.bulk({
214202
console.log(result)
215203
```
216204

217-
218205
### Modifying a document before operation [_modifying_a_document_before_operation]
219206

220207
Added in `v8.8.2`
@@ -241,14 +228,12 @@ const result = await client.helpers.bulk({
241228
console.log(result)
242229
```
243230

244-
245231
## Multi search helper [multi-search-helper]
246232

247233
Added in `v7.8.0`
248234

249235
If you send search request at a high rate, this helper might be useful for you. It uses the multi search API under the hood to batch the requests and improve the overall performances of your application. The `result` exposes a `documents` property as well, which allows you to access directly the hits sources.
250236

251-
252237
### Usage [_usage_4]
253238

254239
```js
@@ -278,7 +263,6 @@ To create a new instance of the multi search (msearch) helper, you should access
278263
| `retries` | How many times an operation is retried before to resolve the request. An operation is retried only in case of a 429 error.<br> *Default:* Client max retries.<br><br>```js<br>const m = client.helpers.msearch({<br> retries: 3<br>})<br>```<br> |
279264
| `wait` | How much time to wait before retries in milliseconds.<br> *Default:* 5000.<br><br>```js<br>const m = client.helpers.msearch({<br> wait: 3000<br>})<br>```<br> |
280265

281-
282266
### Stopping the msearch helper [_stopping_the_msearch_helper]
283267

284268
If needed, you can stop an msearch processor at any time. The msearch helper returns a [thenable](https://promisesaplus.com/), which has an `stop` method.
@@ -291,7 +275,6 @@ The `stop` method accepts an optional error, that will be dispatched every subse
291275
The stop method stops the execution of the msearch processor, but if you are using a concurrency higher than one, the operations that are already running will not be stopped.
292276
::::
293277

294-
295278
```js
296279
const { Client } = require('@elastic/elasticsearch')
297280

@@ -318,7 +301,6 @@ m.search(
318301
setImmediate(() => m.stop())
319302
```
320303

321-
322304
## Search helper [search-helper]
323305

324306
Added in `v7.7.0`
@@ -340,7 +322,6 @@ for (const doc of documents) {
340322
}
341323
```
342324

343-
344325
## Scroll search helper [scroll-search-helper]
345326

346327
Added in `v7.7.0`
@@ -362,7 +343,6 @@ for await (const result of scrollSearch) {
362343
}
363344
```
364345

365-
366346
### Clear a scroll search [_clear_a_scroll_search]
367347

368348
If needed, you can clear a scroll search by calling `result.clear()`:
@@ -375,7 +355,6 @@ for await (const result of scrollSearch) {
375355
}
376356
```
377357

378-
379358
### Quickly getting the documents [_quickly_getting_the_documents]
380359

381360
If you only need the documents from the result of a scroll search, you can access them via `result.documents`:
@@ -386,7 +365,6 @@ for await (const result of scrollSearch) {
386365
}
387366
```
388367

389-
390368
## Scroll documents helper [scroll-documents-helper]
391369

392370
Added in `v7.7.0`
@@ -408,15 +386,12 @@ for await (const doc of scrollSearch) {
408386
}
409387
```
410388

411-
412389
## ES|QL helper [esql-helper]
413390

414391
ES|QL queries can return their results in [several formats](docs-content://explore-analyze/query-filter/languages/esql-rest.md#esql-rest-format). The default JSON format returned by ES|QL queries contains arrays of values for each row, with column names and types returned separately:
415392

416-
417393
### Usage [_usage_5]
418394

419-
420395
#### `toRecords` [_torecords]
421396

422397
Added in `v8.14.0`
@@ -494,7 +469,6 @@ const result = await client.helpers
494469
.toRecords<EventLog>()
495470
```
496471

497-
498472
#### `toArrowReader` [_toarrowreader]
499473

500474
Added in `v8.16.0`
@@ -516,7 +490,6 @@ for (const recordBatch of reader) {
516490
}
517491
```
518492

519-
520493
#### `toArrowTable` [_toarrowtable]
521494

522495
Added in `v8.16.0`

docs/reference/configuration.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ mapped_pages:
77

88
The client is designed to be easily configured for your needs. In the following section, you can see the possible options that you can use to configure it.
99

10-
* [Basic configuration](/reference/basic-config.md)
11-
* [Advanced configuration](/reference/advanced-config.md)
12-
* [Timeout best practices](docs-content://troubleshoot/elasticsearch/elasticsearch-client-javascript-api/nodejs.md)
13-
* [Creating a child client](/reference/child.md)
14-
* [Testing](/reference/client-testing.md)
15-
16-
17-
18-
19-
10+
- [Basic configuration](/reference/basic-config.md)
11+
- [Advanced configuration](/reference/advanced-config.md)
12+
- [Timeout best practices](docs-content://troubleshoot/elasticsearch/elasticsearch-client-javascript-api/nodejs.md)
13+
- [Creating a child client](/reference/child.md)
14+
- [Testing](/reference/client-testing.md)

0 commit comments

Comments
 (0)