Changelogedit

7.7.1edit

Fixesedit

Disable client Helpers in Node.js < 10 - #1194edit

The client helpers can’t be used in Node.js < 10 because it needs a custom flag to be able to use them. Given that not every provider allows the user to specify cuatom Node.js flags, the Helpers has been disabled completely in Node.js < 10.

Force lowercase in all headers - #1187edit

Now all the user-provided headers names will be lowercased by default, so there will be no conflicts in case of the same header with different casing.

7.7.0edit

Featuresedit

Support for Elasticsearch v7.7.edit

You can find all the API changes here.

Introduced client helpers - #1107edit

From now on, the client comes with an handy collection of helpers to give you a more comfortable experience with some APIs.

The client helpers are experimental, and the API may change in the next minor releases.

The following helpers has been introduced:

  • client.helpers.bulk
  • client.helpers.search
  • client.helpers.scrollSearch
  • client.helpers.scrollDocuments

The ConnectionPool.getConnection now always returns a Connection - #1127edit

What does this mean? It means that you will see less NoLivingConnectionError, which now can only be caused if you set a selector/filter too strict. For improving the debugging experience, the NoLivingConnectionsError error message has been updated.

Abortable promises - #1141edit

From now on, it will be possible to abort a request generated with the promise-styl API. If you abort a request generated from a promise, the promise will be rejected with a RequestAbortedError.

const promise = client.search({
  body: {
    query: { match_all: {} }
  }
})

promise
  .then(console.log)
  .catch(console.log)

promise.abort()

Major refactor of the Type Definitions - #1119 #1130 #1132edit

Now every API makes better use of the generics and overloading, so you can (or not, by default request/response bodies are Record<string, any>) define the request/response bodies in the generics.

// request and response bodies are generics
client.search(...)
// response body is `SearchResponse` and request body is generic
client.search<SearchResponse>(...)
// request body is `SearchBody` and response body is `SearchResponse`
client.search<SearchResponse, SearchBody>(...)

This should not be a breaking change, as every generics defaults to any. It might happen to some users that the code breaks, but our test didn’t detect any of it, probably because they were not robust enough. However, given the gigantic improvement in the developer experience, we have decided to release this change in the 7.x line.

Fixesedit

The ConnectionPool.update method now cleans the dead list - #1122 #1127edit

It can happen in a situation where we are updating the connections list and running sniff, leaving the dead list in a dirty state. Now the ConnectionPool.update cleans up the dead list every time, which makes way more sense given that all the new connections are alive.

ConnectionPoolmarkDead should ignore connections that no longer exists - #1159edit

It might happen that markDead is called just after a pool update, and in such case, the clint was adding the dead list a node that no longer exists, causing unhandled exceptions later.

Do not retry a request if the body is a stream - #1143edit

The client should not retry if it’s sending a stream body, because it should store in memory a copy of the stream to be able to send it again, but since it doesn’t know in advance the size of the stream, it risks to take too much memory. Furthermore, copying everytime the stream is very an expensive operation.

Return an error if the request has been aborted - #1141edit

Until now, aborting a request was blocking the HTTP request, but never calling the callback or resolving the promise to notify the user. This is a bug because it could lead to dangerous memory leaks. From now on if the user calls the request.abort() method, the callback style API will be called with a RequestAbortedError, the promise will be rejected with RequestAbortedError as well.

7.6.1edit

Fixes:

  • Secure json parsing - #1110
  • ApiKey should take precedence over basic auth - #1115

Documentation:

  • Fix typo in api reference - #1109

7.6.0edit

Support for Elasticsearch v7.6.

7.5.1edit

Fixes:

  • Skip compression in case of empty string body - #1080
  • Fix typo in NoLivingConnectionsError - #1045
  • Change TransportRequestOptions.ignore to number[] - #1053
  • ClientOptions["cloud"] should have optional auth fields - #1032

Documentation:

  • Docs: Return super in example Transport subclass - #980
  • Add examples to reference - #1076
  • Added new examples - #1031

7.5.0edit

Support for Elasticsearch v7.5.

Features

  • X-Opaque-Id support #997

7.4.0edit

Support for Elasticsearch v7.4.

Fixes:

  • Fix issue; node roles are defaulting to true when undefined is breaking usage of nodeFilter option - #967

Documentation:

  • Updated API reference doc - #945 #969
  • Fix inaccurate description sniffEndpoint - #959

Internals:

  • Update code generation #969

7.3.0edit

Support for Elasticsearch v7.3.

Features:

  • Added auth option - #908
  • Added support for ApiKey authentication - #908

Fixes:

  • fix(Typings): sniffInterval can also be boolean - #914

Internals:

  • Refactored connection pool - #913

Documentation:

  • Better reference code examples - #920
  • Improve README - #909

7.2.0edit

Support for Elasticsearch v7.2

Fixes:

  • Remove auth data from inspect and toJSON in connection class - #887

7.1.0edit

Support for Elasticsearch v7.1

Fixes:

  • Support for non-friendly chars in url username and password - #858
  • Patch deprecated parameters - #851

7.0.1edit

Fixes:

  • Fix TypeScript export (issue #841) - #842
  • Fix http and https port handling (issue #843) - #845
  • Fix TypeScript definiton (issue #803) - #846
  • Added toJSON method to Connection class (issue #848) - #849

7.0.0edit

Support for Elasticsearch v7.0

  • Stable release.