WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Elastic Cloud
editElastic Cloud
editIf you are using Elastic Cloud, the client offers a easy way to connect to it via the cloud
option.
You must pass the Cloud ID that you can find in the cloud console, then your username and password.
When connecting to Elastic Cloud, the client will automatically enable both request and response compression by default, since it yields significant throughput improvements.
Moreover, the client will also set the ssl option secureProtocol
to TLSv1_2_method
unless specified otherwise.
You can still override this option by configuring them.
Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, Elastic Cloud will take care of everything for you.
const { Client } = require('@elastic/elasticsearch') const client = new Client({ cloud: { id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', username: 'elastic', password: 'changeme' } })