# Max\_num\_segments is not working for forcemerge

**URL:** https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855
**Category:** Elasticsearch
**Created:** [April 7, 2020, 9:05am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855 "2020-04-07T09:05:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![quweiyu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quweiyu/32/65591_2.png) [@quweiyu](https://discuss.elastic.co/u/quweiyu)
#### Post date: [April 7, 2020, 9:05am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855/1 "2020-04-07T09:05:34Z")

</div>

All,

I am going to do force merge for one of index (4 primary shard and 0 replica). To reduce the IO impact, I'd like to merge into 4 segments for each shard. So I use following command,

POST /rms\_pl\_03-viewer-cdr-invite-2020040518/\_forcemerge?max\_num\_segments=4

After merge is done, we can see each shard is merged to 1 segment rather than 4. My Elasticsaech version is 6.5. Could you please let me know why is seems like max\_num\_segments=4 is not working ? Thanks much in advanced.

index shard size generation docs.count size.memory docs.deleted committed searchable compound  
rms\_pl\_03-viewer-cdr-invite-2020040518 0 3.8gb 259 1921532 8179330 0 true true false  
rms\_pl\_03-viewer-cdr-invite-2020040518 1 3.7gb 288 1864142 7988849 0 true true false  
rms\_pl\_03-viewer-cdr-invite-2020040518 2 3.7gb 274 1854965 7968941 0 true true false  
rms\_pl\_03-viewer-cdr-invite-2020040518 3 3.7gb 260 1859372 7967752 0 true true false

Thanks,  
Jill

---

<div class="post-metadata">

### Author: ![quweiyu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quweiyu/32/65591_2.png) [@quweiyu](https://discuss.elastic.co/u/quweiyu)
#### Post date: [April 7, 2020, 9:16am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855/2 "2020-04-07T09:16:05Z")

</div>

Is that because max\_num\_segments only define the max number segments not the accurate number segments per shard ?

In other word, the actual number of segment per shard after force merge cannot be defined.

If it is true, would you please help understand why and what is algorithm for force merge ?

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [April 7, 2020, 9:45am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855/3 "2020-04-07T09:45:24Z")

</div>

Yes, `max_num_segments` is a maximum not a target and you may get fewer segments than requested if it makes more sense to do so. I am guessing you end up with one segment since these shards are rather small, just a few GB.

---

<div class="post-metadata">

### Author: ![quweiyu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quweiyu/32/65591_2.png) [@quweiyu](https://discuss.elastic.co/u/quweiyu)
#### Post date: [April 8, 2020, 1:11am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855/4 "2020-04-08T01:11:57Z")

</div>

Thanks much. But would you please let me know in which situation multiple segments will be generated after force merge ? 5G per shard ? and how force merge works ?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 6, 2020, 1:12am UTC](https://discuss.elastic.co/t/max-num-segments-is-not-working-for-forcemerge/226855/5 "2020-05-06T01:12:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
