Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

A way to check for existence of an index or river? #27

Open
victor73 opened this issue Aug 24, 2012 · 4 comments
Open

A way to check for existence of an index or river? #27

victor73 opened this issue Aug 24, 2012 · 4 comments

Comments

@victor73
Copy link

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");
    }
}); 
@rgrove
Copy link
Owner

rgrove commented Aug 24, 2012

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?

@victor73
Copy link
Author

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...

@victor73
Copy link
Author

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...

@rgrove
Copy link
Owner

rgrove commented Aug 25, 2012

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants