[Backport 7.x] Documentation fixes (#1218)
Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
committed by
delvedor
parent
0087c49987
commit
847637d784
@ -106,27 +106,22 @@ const client = new Client({
|
|||||||
|
|
||||||
=== SSL configuration
|
=== SSL configuration
|
||||||
|
|
||||||
Without any additional configuration you can specify `https://` node urls, but
|
Without any additional configuration you can specify `https://` node urls, and
|
||||||
the certificates used to sign these requests will not verified
|
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()`]
|
||||||
(`rejectUnauthorized: false`). To turn on certificate verification, you must
|
uses.
|
||||||
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.
|
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
----
|
----
|
||||||
const { Client } = require('@elastic/elasticsearch')
|
const { Client } = require('@elastic/elasticsearch')
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
node: 'http://localhost:9200',
|
node: 'https://localhost:9200',
|
||||||
auth: {
|
auth: {
|
||||||
username: 'elastic',
|
username: 'elastic',
|
||||||
password: 'changeme'
|
password: 'changeme'
|
||||||
},
|
},
|
||||||
ssl: {
|
ssl: {
|
||||||
ca: fs.readFileSync('./cacert.pem'),
|
ca: fs.readFileSync('./cacert.pem'),
|
||||||
rejectUnauthorized: true
|
rejectUnauthorized: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
----
|
----
|
||||||
@ -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
|
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.
|
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,
|
* The `plugins` option has been removed. If you want to extend the client now,
|
||||||
you should use the `client.extend` API.
|
you should use the `client.extend` API.
|
||||||
|
|
||||||
|
|||||||
@ -76,11 +76,11 @@ auth: {
|
|||||||
_Default:_ `3`
|
_Default:_ `3`
|
||||||
|
|
||||||
|`requestTimeout`
|
|`requestTimeout`
|
||||||
|`number` - Max request timeout for each request. +
|
|`number` - Max request timeout in milliseconds for each request. +
|
||||||
_Default:_ `30000`
|
_Default:_ `30000`
|
||||||
|
|
||||||
|`pingTimeout`
|
|`pingTimeout`
|
||||||
|`number` - Max ping request timeout for each request. +
|
|`number` - Max ping request timeout in milliseconds for each request. +
|
||||||
_Default:_ `3000`
|
_Default:_ `3000`
|
||||||
|
|
||||||
|`sniffInterval`
|
|`sniffInterval`
|
||||||
|
|||||||
@ -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
|
==== 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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ The supported request specific options are:
|
|||||||
_Default:_ `null`
|
_Default:_ `null`
|
||||||
|
|
||||||
|`requestTimeout`
|
|`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`
|
_Default:_ `30000`
|
||||||
|
|
||||||
|`maxRetries`
|
|`maxRetries`
|
||||||
@ -194,32 +194,64 @@ console.log(errors)
|
|||||||
|
|
||||||
You can find the errors exported by the client in the table below.
|
You can find the errors exported by the client in the table below.
|
||||||
|
|
||||||
[cols=2*]
|
[cols=3*]
|
||||||
|===
|
|===
|
||||||
|
|*Error*
|
||||||
|
|*Description*
|
||||||
|
|*Properties*
|
||||||
|
|
||||||
|`ElasticsearchClientError`
|
|`ElasticsearchClientError`
|
||||||
|Every error inherits from this class, it is the basic error generated by the client.
|
|Every error inherits from this class, it is the basic error generated by the client.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
|
||||||
|`TimeoutError`
|
|`TimeoutError`
|
||||||
|Generated when a request exceeds the `requestTimeout` option.
|
|Generated when a request exceeds the `requestTimeout` option.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
* `meta` - `object`, contains all the information about the request
|
||||||
|
|
||||||
|`ConnectionError`
|
|`ConnectionError`
|
||||||
|Generated when an error occurs during the request, it can be a connection error or a malformed stream of data.
|
|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`
|
|`RequestAbortedError`
|
||||||
|Generated if the user calls the `request.abort()` method.
|
|Generated if the user calls the `request.abort()` method.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
* `meta` - `object`, contains all the information about the request
|
||||||
|
|
||||||
|`NoLivingConnectionsError`
|
|`NoLivingConnectionsError`
|
||||||
|Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.
|
|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`
|
|`SerializationError`
|
||||||
|Generated if the serialization fails.
|
|Generated if the serialization fails.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
* `data` - `object`, the object to serialize
|
||||||
|
|
||||||
|`DeserializationError`
|
|`DeserializationError`
|
||||||
|Generated if the deserialization fails.
|
|Generated if the deserialization fails.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
* `data` - `string`, the string to deserialize
|
||||||
|
|
||||||
|`ConfigurationError`
|
|`ConfigurationError`
|
||||||
|Generated if there is a malformed configuration or parameter.
|
|Generated if there is a malformed configuration or parameter.
|
||||||
|
a|* `name` - `string`
|
||||||
|
* `message` - `string`
|
||||||
|
|
||||||
|`ResponseError`
|
|`ResponseError`
|
||||||
|Generated when in case of a `4xx` or `5xx` response.
|
|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
|
||||||
|===
|
|===
|
||||||
|
|||||||
Reference in New Issue
Block a user