1

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
  • 10,322
  • 37
  • 139
  • 253

2 Answers2

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
  • 207,596
  • 13
  • 358
  • 360
0

Yes, we can follow the Delete by Query section on documentation:

let's say that your index is named 'index_test'. So, you can send a POST request to your index_url + '_delete_by_query', so the content (document) of your index will be deleted but the index itself will be preserved:

curl -X POST http://elasticAddress:9200/index_test/_delete_by_query

With this, you will not lose your visualization content as the index is preserved, but the document (content) is updated.