'How to specify multiple host in elasticsearch npm package?
I am using this npm package for elasticsearch -
"@elastic/elasticsearch": "^7.15.0".
I try to specify multiple hosts in the node part but its not working -
const {
Client
} = require('@elastic/elasticsearch');
const client = new Client({
node: [ 'http://localhost:9200','http://localhost:9201']
})```
With a single IP it works fine, but its not taking an array of ip addresses. I even tried the now deprecated elasticsearch package but to no avail. Can somebody please help?
Solution 1:[1]
According to the official documentation, you need to specify the nodes setting instead of node, like this:
const {
Client
} = require('@elastic/elasticsearch');
const client = new Client({
nodes: [ 'http://localhost:9200','http://localhost:9201']
}) ^
|
add 's' here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
