Support for Elasticsearch 7.7 (#1192)

This commit is contained in:
Tomas Della Vedova
2020-05-14 09:55:54 +02:00
committed by GitHub
parent be6257380e
commit 51169d5efa
258 changed files with 15839 additions and 1485 deletions

View File

@ -67,45 +67,34 @@ client.search({
=== Aborting a request
When using the callback style API, the function also returns an object that
allows you to abort the API request.
If needed, you can abort a running request by calling the `request.abort()` method returned by the API.
CAUTION: If you abort a request, the request will fail with a `RequestAbortedError`.
[source,js]
----
// calback API
const request = client.search({
index: 'my-index',
body: { foo: 'bar' }
}, {
ignore: [404],
maxRetries: 3
}, (err, { body }) => {
if (err) console.log(err)
}, (err, result) => {
if (err) {
console.log(err) // RequestAbortedError
} else {
console.log(result)
}
})
request.abort()
----
Aborting a request with the promise style API is not supported, but you can
achieve that with convenience wrapper.
The same behavior is valid for the promise style API as well.
[source,js]
----
function abortableRequest (params, options) {
var request = null
const promise = new Promise((resolve, reject) => {
request = client.search(params, options, (err, result) => {
err ? reject(err) : resolve(res)
})
})
return {
promise,
abort: () => request.abort()
}
}
const request = abortableRequest({
const request = client.search({
index: 'my-index',
body: { foo: 'bar' }
}, {
@ -113,8 +102,11 @@ const request = abortableRequest({
maxRetries: 3
})
request
.then(result => console.log(result))
.catch(err => console.log(err)) // RequestAbortedError
request.abort()
// access the promise with `request.promise.[method]`
----
@ -204,7 +196,7 @@ You can find the errors exported by the client in the table below.
[cols=2*]
|===
|`ElasticsearchClientErrors`
|`ElasticsearchClientError`
|Every error inherits from this class, it is the basic error generated by the client.
|`TimeoutError`
@ -213,8 +205,11 @@ You can find the errors exported by the client in the table below.
|`ConnectionError`
|Generated when an error occurs during the request, it can be a connection error or a malformed stream of data.
|`RequestAbortedError`
|Generated if the user calls the `request.abort()` method.
|`NoLivingConnectionsError`
|Generated in case of all connections present in the connection pool are dead.
|Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.
|`SerializationError`
|Generated if the serialization fails.