IMPORTANT: elasticsearch.js has been replaced by the new Elasticsearch JavaScript client. We strongly advise you to migrate to the new client. To learn more, see the migration guide.
Callbacks or Promises
editCallbacks or Promises
editWhen a callback is passed to any of the API methods, it will be called with (err, response, status)
. If you prefer to use promises, don’t pass a callback and a promise will be returned. The promise will either be resolved with the response body, or rejected with the error that occured (including any 300+ response for non "exists" methods).
Both styles of calling the API will return an object (either a promise or just a plain object) which has an abort()
method. Calling that abort method ends the HTTP request, but it will not end the work Elasticsearch is doing.