On my elasticsearch server: total documents: 3 million, total size: 3.6G Then, I delete about 2.8 millions documents: total documents: about 0.13 million, total size: 3.6G>
In the current elasticsearch version(7.5),
To optimize all indices:
POST /_forcemerge?only_expunge_deletes=true
To optimize single index
POST /twitter/_forcemerge?only_expunge_deletes=true , where twitter is the index
To optimize several indices
POST /twitter,facebook/_forcemerge?only_expunge_deletes=true , where twitter and facebook are the indices
Reference: https://www.elastic.co/guide/en/elasticsearch/reference/7.5/indices-forcemerge.html#indices-forcemerge