IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Transport

edit

This class is responsible to perform the request to Elasticsearch and handling errors, it also handle the sniffing.

const { Client, Transport } = require('@elastic/elasticsearch')

class MyTransport extends Transport {
  request (params, options, callback) {
    // your code
  }
}

const client = new Client({
    Transport: MyTransport
})

Sometimes you just need to inject a little snippet of your code and then continue to use the usual client code, in such case, you should call super.method.

class MyTransport extends Transport {
  request (params, options, callback) {
    // your code
    return super.request(params, options, callback)
  }
}