phillro/node-elasticsearch-client

In the event that an array of hosts is passed in, the other options get over-written in ElasticSearch.prototype.createCall

Opened this issue · 0 comments

The block of code that round-robins the hosts will cause other properties that are part of the options argument to get over-written. (For instance, auth, and secure settings)

The line:
if (options.hosts) {
var nextHost = options.hosts.shift();
options.hosts.push(nextHost);
}

assumes that the options object only contains a hosts property.

ElasticSearchClient.prototype.createCall = function(params, options, cb) {
//If options.hosts round robin the hosts
if (options.hosts) {
var nextHost = options.hosts.shift();
options.hosts.push(nextHost);
}else{
nextHost=options;
}
if(typeof cb=='function'){
var call = new ElasticSearchCall(params, nextHost, cb);
call.exec();
}else{
return new ElasticSearchCall(params, nextHost);
}

}