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.
Basic Auth
editBasic Auth
editBasic authentication credentials can be configured on a per-host basis using URL notation, or at the auth:
property of a host config object.
Credentials directly in the host url:
var client = new elasticsearch.Client({ host: 'https://user:password@my-site.com:9200' })
Credentials as a property of the host config:
var client = new elasticsearch.Client({ host: [ { host: 'es1.internal.org', auth: 'user:password', protocol: 'https', port: 9200 } ] });