# How to force a forcemerge?

**URL:** <https://discuss.elastic.co/t/how-to-force-a-forcemerge/305090>\
**Category:** Elasticsearch\
**Created:** [May 18, 2022, 3:50pm UTC](https://discuss.elastic.co/t/how-to-force-a-forcemerge/305090 "2022-05-18T15:50:07Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![nisow95612](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nisow95612](https://discuss.elastic.co/u/nisow95612)\
**Post date:** [June 1, 2022, 8:35am UTC](https://discuss.elastic.co/t/how-to-force-a-forcemerge/305090/8 "2022-06-01T08:35:42Z")

</div>

> [@stephenb](#):
>
> So I assume you did this by closing the index and setting the codec and then re-opening the index... Correct?  
> And you did this when you already have a single segment?  
> And that segment was already BEST\_SPEED?

Yes, you got it right.

- Technically I asked ILM to do it, but AFAIK ILM does exactly what you describe.
- Yes, I am having trouble switching coded on shards that already have only one segment.
- Yes. But I would say that segment was _still_ BEST\_SPEED.

> [@stephenb](#):
>
> It the answer to all those are yes... then I do not think forcemerge will work, as you experienced. I think if you will have to reindex.
> 
> Once you have one segment forvemerge is not going to do anything because it's about merging segments not the codec.. using the new codec It's just a side benefit when an actual merge is done

Yes, that is the reason why I opened this topic. I do not want to reindex _again_. Reindexing is what caused my problems, because I hit [\_source 50% bigger after reindex](https://discuss.elastic.co/t/source-50-bigger-after-reindex/303805). Now I need to switch codecs to get that disk space back.

> [@stephenb](#):
>
> If you set the `best_compression` BEFORE you were merged to one segment then perhaps... I would need to test.
> 
> BTW I did test if you use forcemerge and it actually executes and merges because you have more than 1 segment it will "honor/use" the new codec.

Yes, any shards that had more segments switched to the new codec.  
I was hoping one of you would suggest a trick to force the forcemerge to run.

E.g. I thought about creating new segments by adding a couple of dummy documents and then deleting them. But I am afraid that forcemerge will be too clever and just delete the new segments.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-force-a-forcemerge/305090)._
