1

I would like to delete all of my document of _type=varnish-request on my elasticsearch. I installed the delete by query plugin (https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html)

I did DELETE http://localhost:9200/logstash*/_query

{
  "query": {
    "bool": {
      "must": [        
        { "match": {"_type":"varnish-request"}},
        { "match": {"_index":"logstash-2016.02.05"}}     
      ]
    }
  }
}

And it's OK

{"took":2265842,"timed_out":false,"_indices":{"_all":{"found":3062614,"deleted":3062614,"missing":0,"failed":0},"logstash-2016.02.05":
{"found":3062614,"deleted":3062614,"missing":0,"failed":0}},"failures":[]}

curl http://localhost:9200/_cat/indices | sort Before the clean

  • yellow open logstash-2016.02.05 5 1 4618245 0 4.1gb 4.1gb

After the clean

  • yellow open logstash-2016.02.05 5 1 1555631 3062605 4.1gb 4.1gb

The whole point is to 'light' my ES server by removing useless data. But here I see that the index size is still the same.

I already check Delete documents of type in Elasticsearch but no luck

I try with elasticsearch: how to free store size after deleting documents

POST http://localhost:9200/logstash-2016.02.05/_forcemerge

{"_shards":{"total":10,"successful":5,"failed":0}}

But still

  • yellow open logstash-2016.02.05 5 1 1555631 3062605 4.1gb 4.1gb
Community
  • 1
  • 1
glmrenard
  • 675
  • 1
  • 8
  • 16

1 Answers1

3

The first step is correct. Now you simply need to call _optimize (or _forcemerge if you're using ES 2.1+) by enabling only_expunge_deletes. This will delete the segments with deleted documents and free some space.

curl -XPOST 'http://localhost:9200/_optimize?only_expunge_deletes=true'

or

curl -XPOST 'http://localhost:9200/_forcemerge?only_expunge_deletes=true'
Val
  • 207,596
  • 13
  • 358
  • 360