Request specific options

edit

If needed you can pass request specific options in a second object:

// promise API
const result = await client.search({
  index: 'my-index',
  body: {
    query: {
      match: { hello: 'world' }
    }
  }
}, {
  ignore: [404],
  maxRetries: 3
})

// callback API
client.search({
  index: 'my-index',
  body: {
    query: {
      match: { hello: 'world' }
    }
  }
}, {
  ignore: [404],
  maxRetries: 3
}, (err, { body }) => {
  if (err) console.log(err)
})

The supported request specific options are:

ignore

[number] -  HTTP status codes which should not be considered errors for this request.
Default: null

requestTimeout

number - Max request timeout for the request, it overrides the client default.
Default: 30000

maxRetries

number - Max number of retries for the request, it overrides the client default.
Default: 3

compression

string, boolean - Enables body compression for the request.
Options: false, 'gzip'
Default: false

asStream

boolean - Instead of getting the parsed body back, you will get the raw Node.js stream of data.
Default: false

headers

object - Custom headers for the request.
Default: null

querystring

object - Custom querystring for the request.
Default: null

id

any - Custom request id. (overrides the top level request id generator)
Default: null

context

any - Custom object per request. (you can use it to pass some data to the clients events)
Default: null