Bex
Bex

Reputation: 593

ElasticSearch Create Index TypeError

I'm using the elasticsearch npm module. Creating an Index results in a TypeError whose message is:

Unable to build a path with those params. Supply at least index

The code I'm using looks like:

    var client = new elasticsearch.Client({
        host: 'localhost:9200',
        log: 'trace'
    });

    client.indices.create('myindex', function (err, resp) {
        if (err)
            console.log('failed to create ElasticSearch index, ' + err.message);
        else
            console.log('successfully created ElasticSearch index');
    });

According to the index create docs, I should be able to pass a string with the name of the index. I am confused as to why it's failing in general, and why the error message refers to a path.

Upvotes: 2

Views: 5182

Answers (1)

Oliver
Oliver

Reputation: 13031

The first argument for create() needs to be a dict. Try:

client.indices.create({index: 'myindex'}, function (err, resp) {
    if (err)
        console.log('failed to create ElasticSearch index, ' + err.message);
    else
        console.log('successfully created ElasticSearch index');
});

Upvotes: 2

Related Questions