Understanding forcemerge with only_expunge_deletes

My scenario is the following:

i have a live index with a lot of updates that runs out of disk space at some time.

The reason is that after some time i have a lot of max size segments (5gb) but the deleted document count is below 50% → The normal merge will not touch them.

My idea is: Can i rewrite the current segments without the deleted documents to give disk space free.

Can a forcemerge with “only_expunge_deletes=true” do the trick for me? Or will this create big segments that create more problems in the future?

the documentation is quite slim on what only_expunge_deletes will really do, e.g. Force a merge | Elasticsearch API documentation

PS: i know the alternative is a complete reindex and deletion of the old index → but this is a quite ressource heavy approach

PS: The question was also asked here but nobody answered: Safe usage of `_forcemerge` with `only_expunge_deletes`

Segments in Elsticsearch are immutable so no matter how you run forcemerge new segments will be created. Even if new segments are created it may be beneficial to run forcemerge the way you described, but be aware it will temporarily increase disk usage. I do not know the internals though and have rarely tried to tune merging so will need to leave that to someone else.

Hi all,

I have a live Elasticsearch index with heavy updates, and over time it starts running out of disk space. Many segments are already at max size (~5GB), but their deleted doc ratio is still below 50%, so normal merges don’t seem to clean them up.

I’m wondering if running forcemerge with only_expunge_deletes=true can help reclaim disk space by removing deleted documents without doing a full reindex.

Does this option simply rewrite existing segments to drop deletes, or can it create large segments that might cause problems later? Any practical guidance or caveats for using this on a live index would be helpful.

Thanks!