问题
When I delete documents from Elasticsearch, why does my 'total size' stay the same despite obviously being far smaller with the absence of previously stored data? I've read about index optimization but I'm not sure what this is or how to do it.
Thanks
回答1:
I'm sure there are tons of questions relating to this on both SO and Google so this may be a duplicate answer. However - deleting documents only marks them as deleted, it doesn't actually remove them from your data store.
In old ES, there used to be a feature named 'optimize' (which is deprecated) - nowdays forcemerge is the enhanced replacement. The following command should free up the space you're entitled to.
curl -XPOST 'http://localhost:9200/_forcemerge?only_expunge_deletes=true'
Here's a bit more info on forcemerge if you're interested:
https://www.elastic.co/blog/found-elasticsearch-from-the-bottom-up
来源:https://stackoverflow.com/questions/45675537/reclaim-disk-space-after-deleting-files-in-elasticsearch