# How to determine max\_num\_segments for force merge?

**URL:** https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334
**Category:** Elasticsearch
**Created:** [October 18, 2016, 10:40pm UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334 "2016-10-18T22:40:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [October 18, 2016, 10:40pm UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/1 "2016-10-18T22:40:39Z")

</div>

Hi All,

In our ES cluster, we have time based indexes from a few GB up to 100+GB (replicas not counted). The cluster uses hot cold model, and I'm looking at force merge ([https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html)) to see if I could optimize the indexes on cold nodes for searching.

I haven't found any guidelines on setting the `max_num_segments` for force merge. For instance, we have weekly indexes at about 120GB each with 4 primary shards, how to deternmine the proper `max_num_segments` when running force merge on those indexes?

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [October 19, 2016, 8:42am UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/2 "2016-10-19T08:42:10Z")

</div>

Hi @anhlqn,

for your use case the optimal number is 1. Force merging is very I/O intensive but if you don't write to this index after force merge (and that's the case here with hot/cold), then Lucene needs to search in only one segment and you also need to do the force merge once.

Daniel

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [October 19, 2016, 11:55pm UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/3 "2016-10-19T23:55:29Z")

</div>

Thanks @danielmitterdorfer. From one of the videos in ElasticON 2016, a support engineer recommended that the size of each shard should be under 50 GB. Would it also be the recommended size for a Lucene segment?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [October 20, 2016, 12:20am UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/4 "2016-10-20T00:20:11Z")

</div>

No, that is not the case.  
There isn't really a recommended segment size, just a shard one.

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [October 21, 2016, 4:19am UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/5 "2016-10-21T04:19:44Z")

</div>

Got it, thanks

---

<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: [July 5, 2017, 10:10pm UTC](https://discuss.elastic.co/t/how-to-determine-max-num-segments-for-force-merge/63334/6 "2017-07-05T22:10:40Z")

</div>


