Release notes
editRelease notes
edit8.6.1
editBump @elastic/transport to ~8.3.1
editSwitching from ^8.3.1
to ~8.3.1
ensures 8.6 client users are not required to update to Node.js v18+, which is a new requirement set by @elastic/transport
v8.5.0. See elastic/elastic-transport-js#91 for details.
8.6.0
editThe @elastic/transport
dependency has been bumped to ~8.3.1
to ensure
fixes to the maxResponseSize
option are available in the client.
Support for Elasticsearch v8.6.0
editYou can find all the API changes here.
8.5.0
editSupport for Elasticsearch v8.5.0
editYou can find all the API changes here.
8.4.0
editSupport for Elasticsearch v8.4.0
editYou can find all the API changes here.
8.2.1
editFixes
editSupport for Elasticsearch v8.2.1
editYou can find all the API changes here.
The previous release contained a bug that broken ndjson APIs.
We have released v8.2.0-patch.1
to address this.
This fix is the same as the one we have released and we strongly recommend upgrading to this version.
The shutdown APIs wheren’t complete, this fix completes them.
The types definitions where wrongly representing the types of fields present in both query and body.
8.2.0
editBreaking changes
editAccording to our Node.js support matrix.
Features
editSupport for Elasticsearch v8.2
editYou can find all the API changes here.
When creating a new client, an undefined
caFingerprint
no longer trigger an error for a http connection.
You can import the full TypeScript requests & responses definitions as it follows:
import { estypes } from '@elastic/elasticsearch'
If you need the legacy definitions with the body, you can do the following:
import { estypesWithBody } from '@elastic/elasticsearch'
Fixes
editUpdated hpagent to the latest version transport/#49
editYou can fing the related changes here.
8.1.0
editFeatures
editSupport for Elasticsearch v8.1
editYou can find all the API changes here.
Now the client exports the SniffingTransport class.
Fixes
editFixes a memory leak caused by an error in the upstream dataset of the bulk helper.
Cleanup abort listener transport/#42
editThe legacy http client was not cleaning up the abort listener, which could cause a memory leak.
Improve undici performances transport/#41
editImprove the stream body collection and keep alive timeout.
8.0.0
editFeatures
editSupport for Elasticsearch v8.0
editYou can find all the API changes here.
Drop old typescript definitions
editBreaking: Yes | Migration effort: Medium
The current TypeScript definitions will be removed from the client, and the new definitions, which contain request and response definitions as well will be shipped by default.
Drop callback-style API
editBreaking: Yes | Migration effort: Large
Maintaining both API styles is not a problem per se, but it makes error handling more convoluted due to async stack traces. Moving to a full-promise API will solve this issue.
// callback-style api client.search({ params }, { options }, (err, result) => { console.log(err || result) }) // promise-style api client.search({ params }, { options }) .then(console.log) .catch(console.log) // async-style (sugar syntax on top of promises) const response = await client.search({ params }, { options }) console.log(response)
If you are already using the promise-style API, this won’t be a breaking change for you.
Remove the current abort API and use the new AbortController standard
editBreaking: Yes | Migration effort: Small
The old abort API makes sense for callbacks but it’s annoying to use with promises
// callback-style api const request = client.search({ params }, { options }, (err, result) => { console.log(err) // RequestAbortedError }) request.abort() // promise-style api const promise = client.search({ params }, { options }) promise .then(console.log) .catch(console.log) // RequestAbortedError promise.abort()
Node v12 has added the standard AbortController
API which is designed to work well with both callbacks and promises.
const ac = new AbortController() client.search({ params }, { signal: ac.signal }) .then(console.log) .catch(console.log) // RequestAbortedError ac.abort()
Remove the body key from the request
editBreaking: Yes | Migration effort: Small
Thanks to the new types we are developing now we know exactly where a parameter should go. The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX.
This could be a rather big breaking change, so a double solution could be used during the 8.x lifecycle. (accepting body keys without them being wrapped in the body as well as the current solution).
// from const response = await client.search({ index: 'test', body: { query: { match_all: {} } } }) // to const response = await client.search({ index: 'test', query: { match_all: {} } })
Migrate to new separate transport
editBreaking: Yes | Migration effort: Small to none
The separated transport has been rewritten in TypeScript and has already dropped the callback style API. Given that now is separated, most of the Elasticsearch specific concepts have been removed, and the client will likely need to extend parts of it for reintroducing them. If you weren’t extending the internals of the client, this won’t be a breaking change for you.
The returned value of API calls is the body and not the HTTP related keys
editBreaking: Yes | Migration effort: Small
The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX. The client will expose a new request-specific option to still get the full response details.
// from const response = await client.search({ index: 'test', body: { query: { match_all: {} } } }) console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array } // to const response = await client.search({ index: 'test', query: { match_all: {} } }) console.log(response) // SearchResponse // with a bit of TypeScript and JavaScript magic... const response = await client.search({ index: 'test', query: { match_all: {} } }, { meta: true }) console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array }
Use a weighted connection pool
editBreaking: Yes | Migration effort: Small to none
Move from the current cluster connection pool to a weight-based implementation. This new implementation offers better performances and runs less code in the background, the old connection pool can still be used. If you weren’t extending the internals of the client, this won’t be a breaking change for you.
Migrate to the "undici" http client
editBreaking: Yes | Migration effort: Small to none
By default, the HTTP client will no longer be the default Node.js HTTP client, but undici instead. Undici is a brand new HTTP client written from scratch, it offers vastly improved performances and has better support for promises. Furthermore, it offers comprehensive and predictable error handling. The old HTTP client can still be used. If you weren’t extending the internals of the client, this won’t be a breaking change for you.
Drop support for old camelCased keys
editBreaking: Yes | Migration effort: Medium
Currently, every path or query parameter could be expressed in both snake_case
and camelCase
. Internally the client will convert everything to snake_case
.
This was done in an effort to reduce the friction of migrating from the legacy to the new client, but now it no longer makes sense.
If you are already using snake_case
keys, this won’t be a breaking change for you.
Rename ssl
option to tls
editBreaking: Yes | Migration effort: Small
People usually refers to this as tls
, furthermore, internally we use the tls API and Node.js refers to it as tls everywhere.
// before const client = new Client({ node: 'https://localhost:9200', ssl: { rejectUnauthorized: false } }) // after const client = new Client({ node: 'https://localhost:9200', tls: { rejectUnauthorized: false } })
Remove prototype poisoning protection
editBreaking: Yes | Migration effort: Small
Prototype poisoning protection is very useful, but it can cause performances issues with big payloads. In v8 it will be removed, and the documentation will show how to add it back with a custom serializer.
Remove client extensions API
editBreaking: Yes | Migration effort: Large
Nowadays the client support the entire Elasticsearch API, and the transport.request
method can be used if necessary. The client extensions API have no reason to exist.
client.extend('utility.index', ({ makeRequest }) => { return function _index (params, options) { // your code } }) client.utility.index(...)
If you weren’t using client extensions, this won’t be a breaking change for you.
Move to TypeScript
editBreaking: No | Migration effort: None
The new separated transport is already written in TypeScript, and it makes sense that the client v8 will be fully written in TypeScript as well.
Move from emitter-like interface to a diagnostic method
editBreaking: Yes | Migration effort: Small
Currently, the client offers a subset of methods of the EventEmitter
class, v8 will ship with a diagnostic
property which will be a proper event emitter.
// from client.on('request', console.log) // to client.diagnostic.on('request', console.log)
Remove username & password properties from Cloud configuration
editBreaking: Yes | Migration effort: Small
The Cloud configuration does not support ApiKey and Bearer auth, while the auth
options does.
There is no need to keep the legacy basic auth support in the cloud configuration.
// before const client = new Client({ cloud: { id: '<cloud-id>', username: 'elastic', password: 'changeme' } }) // after const client = new Client({ cloud: { id: '<cloud-id>' }, auth: { username: 'elastic', password: 'changeme' } })
If you are already passing the basic auth options in the auth
configuration, this won’t be a breaking change for you.
Calling client.close
will reject new requests
editOnce you call client.close
every new request after that will be rejected with a NoLivingConnectionsError
. In-flight requests will be executed normally unless an in-flight request requires a retry, in which case it will be rejected.
Parameters rename
edit-
ilm.delete_lifecycle
:policy
parameter has been renamed toname
-
ilm.get_lifecycle
:policy
parameter has been renamed toname
-
ilm.put_lifecycle
:policy
parameter has been renamed toname
-
snapshot.cleanup_repository
:repository
parameter has been renamed toname
-
snapshot.create_repository
:repository
parameter has been renamed toname
-
snapshot.delete_repository
:repository
parameter has been renamed toname
-
snapshot.get_repository
:repository
parameter has been renamed toname
-
snapshot.verify_repository
:repository
parameter has been renamed toname
Removal of snake_cased methods
editThe v7 client provided snake_cased methods, such as client.delete_by_query
. This is no longer supported, now only camelCased method are present.
So client.delete_by_query
can be accessed with client.deleteByQuery