node-elastical
node-elastical copied to clipboard
A way to check for existence of an index or river?
Is there a way to check for the existence of a particular index? I found the indexExists() method, however it doesn't seem to be documented or to work as expected. An index name that definitely exists according to the output of a curl call to /_status and /index_name/_status seems to return false when passed to indexExists():
client.indexExists(indexName, function(err, exists) {
if (err) {
throw err;
}
if (exists) {
console.log("Exists");
} else {
console.log("Doesn't exist");
}
});
Client#indexExists()
is documented here: https://github.com/rgrove/node-elastical/blob/master/lib/client.js#L339-352
It calls the static Index.exists()
method, which is documented here: https://github.com/rgrove/node-elastical/blob/master/lib/index.js#L256-279
The unit tests for this method pass, so it seems to be working. Can you give me more details about your ElasticSearch version, or possibly write a failing unit test that demonstrates the problem in a reproducible way?
The elasticsearch version is 18.6:
$ curl -X GET server:9200 | json version.number
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 361 100 361 0 0 152k 0 --:--:-- --:--:-- --:--:-- 0
{
"version": {
"number": "0.18.6"
}
}
I'll try to write a test to demonstrate...
Ugh. Seems like I was supplying "http://" at the beginning of the value for the server. Once I remove the "http://" it works fine. My mistake. However, I think some sort of exception should have been thrown in this case...
Hmm, yeah, Index.exists()
ought to pass along the error from Request if there is one, and there should be one in that case. That's a valid bug, thanks!