0
在我的节点应用程序中,我使用“Elasticsearch
”进行数据检索。当我只连接到1台主机时,它工作正常。node.js elasticsearch多个主机
为前:
try {
elasticSearchClient = new ElasticSearchClient({
host: 'xxx.xxx.x.xxxx',
port: '9200'
});
} catch (err) {
console.log('err=' + err);
}
但是当我试图连接到多台主机(例如)我得到错误:
对于前:
var serverOptions = {
hosts:[
{
host: 'xxx.xxx.x.xxx',
port: 9200
},{
host: 'xxx.xxx.x.xxx',
port: 9200
}]
};
elasticSearchClient = new ElasticSearchClient(serverOptions);
错误:
ECONN REFUSED: socket hang up
我正在使用“elsaticsearchclient
”节点包。帮我解决这个问题。在此先感谢..
编辑:
其实1主机已启动并在另一台主机宕机。所以当主机1关闭时,我不得不重定向到另一个主机..我如何实现这一目标?
Thannks。但是我们用“elasticsearch”包,但我使用“elasticsearchclient”包..所以,如果你使用上面code.i不必须。对方法.. – Subburaj 2014-09-10 11:20:59
你没没有提及你使用过哪个客户端,所以我假定你使用的是官方模块,而不是第三方。我建议你这样做。 – Eye 2014-09-10 11:23:07
K.我需要为第三方软件包做些什么.. – Subburaj 2014-09-10 11:25:03