diff --git a/docs/authentication.asciidoc b/docs/authentication.asciidoc index c27553913..7866d8c74 100644 --- a/docs/authentication.asciidoc +++ b/docs/authentication.asciidoc @@ -106,27 +106,22 @@ const client = new Client({ === SSL configuration -Without any additional configuration you can specify `https://` node urls, but -the certificates used to sign these requests will not verified -(`rejectUnauthorized: false`). To turn on certificate verification, you must -specify an `ssl` object either in the top level config or in each host config -object and set `rejectUnauthorized: true`. The ssl config object can contain -many of the same configuration options that -https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[tls.connect()] -accepts. +Without any additional configuration you can specify `https://` node urls, and +the certificates used to sign these requests will be verified. To turn off certificate verification, you must specify an `ssl` object in the top level config and set `rejectUnauthorized: false`. The default `ssl` values are the same that Node.js's https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`] +uses. [source,js] ---- const { Client } = require('@elastic/elasticsearch') const client = new Client({ - node: 'http://localhost:9200', + node: 'https://localhost:9200', auth: { username: 'elastic', password: 'changeme' }, ssl: { ca: fs.readFileSync('./cacert.pem'), - rejectUnauthorized: true + rejectUnauthorized: false } }) ---- \ No newline at end of file diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index fb8dc3b76..03675b346 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -95,6 +95,16 @@ error, such as `statusCode`, `headers`, `body`, and `message`. version, you can specify the host and port in a variety of ways. With the new client, there is only one way to do it, via the `node` parameter. +* Certificates are verified by default, if you want to disable certificates verification, you should set the `rejectUnauthorized` option to `false` inside the `ssl` configuration: + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + ssl: { rejectUnauthorized: false } +}) +---- + * The `plugins` option has been removed. If you want to extend the client now, you should use the `client.extend` API. diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 669126a17..6182effec 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -76,11 +76,11 @@ auth: { _Default:_ `3` |`requestTimeout` -|`number` - Max request timeout for each request. + +|`number` - Max request timeout in milliseconds for each request. + _Default:_ `30000` |`pingTimeout` -|`number` - Max ping request timeout for each request. + +|`number` - Max ping request timeout in milliseconds for each request. + _Default:_ `3000` |`sniffInterval` diff --git a/docs/helpers.asciidoc b/docs/helpers.asciidoc index 8435ffa3e..67cb1c94e 100644 --- a/docs/helpers.asciidoc +++ b/docs/helpers.asciidoc @@ -150,6 +150,64 @@ const b = client.helpers.bulk({ |=== +==== Supported operations + +===== Index +[source,js] +---- +client.helpers.bulk({ + datasource: myDatasource, + onDocument (doc) { + return { + index: { _index: 'my-index' } + } + } +}) +---- + +===== Create +[source,js] +---- +client.helpers.bulk({ + datasource: myDatasource, + onDocument (doc) { + return { + create: { _index: 'my-index', _id: doc.id } + } + } +}) +---- + +===== Update +[source,js] +---- +client.helpers.bulk({ + datasource: myDatasource, + onDocument (doc) { + // Note that the update operation requires you to return + // an array, where the first element is the actio, while + // the second are the document option + return [ + { update: { _index: 'my-index', _id: doc.id } }, + { doc_as_upsert: true } + ] + } +}) +---- + +===== Delete +[source,js] +---- +client.helpers.bulk({ + datasource: myDatasource, + onDocument (doc) { + return { + delete: { _index: 'my-index', _id: doc.id } + } + } +}) +---- + ==== Abort a bulk operation If needed, you can abort a bulk operation at any time. The bulk helper returns a https://promisesaplus.com/[thenable], which has an `abort` method. diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index c279b886d..2af2f84a9 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -145,7 +145,7 @@ The supported request specific options are: _Default:_ `null` |`requestTimeout` -|`number` - Max request timeout for the request, it overrides the client default. + +|`number` - Max request timeout for the request in milliseconds, it overrides the client default. + _Default:_ `30000` |`maxRetries` @@ -194,32 +194,64 @@ console.log(errors) You can find the errors exported by the client in the table below. -[cols=2*] +[cols=3*] |=== +|*Error* +|*Description* +|*Properties* + |`ElasticsearchClientError` |Every error inherits from this class, it is the basic error generated by the client. +a|* `name` - `string` +* `message` - `string` |`TimeoutError` |Generated when a request exceeds the `requestTimeout` option. +a|* `name` - `string` +* `message` - `string` +* `meta` - `object`, contains all the information about the request |`ConnectionError` |Generated when an error occurs during the request, it can be a connection error or a malformed stream of data. +a|* `name` - `string` +* `message` - `string` +* `meta` - `object`, contains all the information about the request |`RequestAbortedError` |Generated if the user calls the `request.abort()` method. +a|* `name` - `string` +* `message` - `string` +* `meta` - `object`, contains all the information about the request |`NoLivingConnectionsError` |Given the configuration, the ConnectionPool was not able to find a usable Connection for this request. +a|* `name` - `string` +* `message` - `string` +* `meta` - `object`, contains all the information about the request |`SerializationError` |Generated if the serialization fails. +a|* `name` - `string` +* `message` - `string` +* `data` - `object`, the object to serialize |`DeserializationError` |Generated if the deserialization fails. +a|* `name` - `string` +* `message` - `string` +* `data` - `string`, the string to deserialize |`ConfigurationError` |Generated if there is a malformed configuration or parameter. +a|* `name` - `string` +* `message` - `string` |`ResponseError` |Generated when in case of a `4xx` or `5xx` response. +a|* `name` - `string` +* `message` - `string` +* `meta` - `object`, contains all the information about the request +* `body` - `object`, the response body +* `statusCode` - `object`, the response headers +* `headers` - `object`, the response status code |===