IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Transport
editTransport
editThis class is responsible for performing the request to Elasticsearch and handling errors, it also handles sniffing.
const { Client } = require('@elastic/elasticsearch') const { Transport } = require('@elastic/transport') class MyTransport extends Transport { request (params, options, callback) { // your code } } const client = new Client({ Transport: MyTransport })
Sometimes you need to inject a small snippet of your code and then continue to
use the usual client code. In such cases, call super.method
:
class MyTransport extends Transport { request (params, options, callback) { // your code return super.request(params, options, callback) } }
Supported content types
editDepending on the content-type
of the response, the transport will return the body as different types:
Content-Type | JavaScript type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|