21

The documentation recommends the following function to delete a specific index:

client.delete({
  index: 'myindex',
  type: 'mytype',
  id: '1'
}, function (error, response) {
  // ...
});

Which I have adapted to:

client.delete({
  index: '_all'
}, function (error, response) {
  // ...
});

But that gives me the following error:

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

I've been searching around for a couple of hours to no avail, anyone have any ideas?

6
  • 1
    The method you copied is for deleting a document, not an index. You want this call. Commented Aug 10, 2015 at 18:52
  • @Tony Could you give an example of how that call would look in practice? I was reviewing that before, but couldn't make sense of how the actual call would look like with the desired parameters. Commented Aug 10, 2015 at 19:25
  • @Tony Nevermind, figured it out. Had to pass in the parameters as a JSON object, my bad. Not that experienced with JavaScript programming yet. Commented Aug 10, 2015 at 19:28
  • You should post your working code as an answer you can accept for completeness. Commented Aug 10, 2015 at 19:34
  • 2
    Not at all. It's fairly common. I'd be more annoyed to see a question with your comment saying, "I figured it out." and then see nothing like the countless forum posts online. =) Commented Aug 10, 2015 at 19:41

1 Answer 1

34

So, turns out I was using the wrong method. The below should take care of deleting all the indexes.

client.indices.delete({
    index: '_all'
}, function(err, res) {

    if (err) {
        console.error(err.message);
    } else {
        console.log('Indexes have been deleted!');
    }
});

You can introduce specific index names within that 'index' parameter, and you can also use '*' as an alternate to '_all'.

Sign up to request clarification or add additional context in comments.

1 Comment

What about removing just based on a type?

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.