# Script for a Force Merge on indexes in ES

**URL:** <https://discuss.elastic.co/t/script-for-a-force-merge-on-indexes-in-es/250021>\
**Category:** Elasticsearch\
**Created:** [September 25, 2020, 7:31pm UTC](https://discuss.elastic.co/t/script-for-a-force-merge-on-indexes-in-es/250021 "2020-09-25T19:31:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticuserxxx](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@elasticuserxxx](https://discuss.elastic.co/u/elasticuserxxx)\
**Post date:** [September 25, 2020, 7:31pm UTC](https://discuss.elastic.co/t/script-for-a-force-merge-on-indexes-in-es/250021/1 "2020-09-25T19:31:44Z")

</div>

I need to run force merge on indexes which are older (no longer being written to or not in active state) for more than "48hours for daily/quaterly indexes" and "33 days for monthly indexes".

This should be run by a script as we have lot many indexes in our environment, could anyone please help on this

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 27, 2020, 6:04pm UTC](https://discuss.elastic.co/t/script-for-a-force-merge-on-indexes-in-es/250021/2 "2020-09-27T18:04:26Z")

</div>

Have you looked into [Index Lifecycle Management](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html), which has support for [forcemerging](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-forcemerge.html)?

---

<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:** [October 25, 2020, 6:04pm UTC](https://discuss.elastic.co/t/script-for-a-force-merge-on-indexes-in-es/250021/3 "2020-10-25T18:04:31Z")

</div>

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