0

First of all, I have already checked this question Removing Data From ElasticSearch

It's not good for me because the answers there are talking about how to delete the whole index., which is different from my question.

my question is that i want to delete the whole document inside one index, but without deleting the index.

i tried to do the flush command, but it doesn't delete anything.

thanks in advance

Community
  • 1
  • 1
Marco Dinatsoli
  • 9,244
  • 33
  • 108
  • 224

1 Answers1

1

If you just need to delete the documents but keep your index, then you may use the delete by query plugin (if you are using ES 2.x) otherwise you may just use the delete by query API (if you're using ES 1.7.x or earlier).

So if you're using ES 2.x, first install the plugin with the command below and restart ES

bin/plugin install delete-by-query

Then you can delete all your documents with the following curl

curl -XDELETE http://localhost:9200/index/_query?q=*
Val
  • 165,097
  • 10
  • 260
  • 279