2

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.

1 Answer 1

2

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');
});
Sign up to request clarification or add additional context in comments.

1 Comment

Excellent. I had to change {name: 'myindex'} to {index: 'myindex'} to get it to work in the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.