# Where is the merge policy defined?

**URL:** <https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496>\
**Category:** Elasticsearch\
**Created:** [May 13, 2020, 6:29pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496 "2020-05-13T18:29:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emanuel\_Velzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuel_velzi/32/66975_2.png) [@Emanuel\_Velzi](https://discuss.elastic.co/u/Emanuel_Velzi)\
**Post date:** [May 13, 2020, 6:29pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/1 "2020-05-13T18:29:20Z")

</div>

Hi, I am using ES 7.6.2 and I can not find the merge policy for my indices. I don't see it in _\_settings_.

In addition, I can not find the default merge policy in the elastic documentation.

Can someone help me please?

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 13, 2020, 6:59pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/2 "2020-05-13T18:59:17Z")

</div>

The documentation on the merge policy is [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html).

The merge policy is the Tiered one.  
It is not usually required to tweak settings which are not documented as they're usually necessary for special edge use cases (e.g. heavy delete use cases).

Other advanced settings are at:

- [https://github.com/elastic/elasticsearch/blob/7b34e22890e15b7480689b216c48487c87385978/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java#L56](https://github.com/elastic/elasticsearch/blob/7b34e22890e15b7480689b216c48487c87385978/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java#L56)
- [https://github.com/elastic/elasticsearch/blob/7b34e22890e15b7480689b216c48487c87385978/server/src/main/java/org/elasticsearch/index/MergePolicyConfig.java#L49](https://github.com/elastic/elasticsearch/blob/7b34e22890e15b7480689b216c48487c87385978/server/src/main/java/org/elasticsearch/index/MergePolicyConfig.java#L49)

---

<div class="post-metadata">

**Author:** ![Emanuel\_Velzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuel_velzi/32/66975_2.png) [@Emanuel\_Velzi](https://discuss.elastic.co/u/Emanuel_Velzi)\
**Post date:** [May 13, 2020, 9:14pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/3 "2020-05-13T21:14:37Z")

</div>

I see that link but it doesn't has so much...

I have a time-based index containing APM transaction metrics (20GB, 2 shards) that isn't receiving data anymore, it is **from yesterday**.

When I inspect the segments, I can see that index has almost **100 segments.**

Should I expect that Elasticsearch by itself merge that segments sometime?  
Or should I execute a **forcemerge** to get only 1 or 2 segments for example?

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 13, 2020, 9:20pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/4 "2020-05-13T21:20:44Z")

</div>

No, do not force merge an index which you are indexing.  
Only read only indices can be force merged without side effects. From the docs:

> Running force merge against a read-write index can cause very large segments to be produced (\>5Gb per segment), and the merge policy will never consider it for merging again until it mostly consists of deleted docs. \>This can cause very large segments to remain in the shards.

Can you check the logs on Elasticsearch side or Apm server side to check if there are errors?  
Are you using ILM? Maybe there's a problem in the index rollover.

---

<div class="post-metadata">

**Author:** ![Emanuel\_Velzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuel_velzi/32/66975_2.png) [@Emanuel\_Velzi](https://discuss.elastic.co/u/Emanuel_Velzi)\
**Post date:** [May 13, 2020, 9:30pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/5 "2020-05-13T21:30:05Z")

</div>

Sorry, maybe I was not clear.

I'm not sending data to that index anymore, it is from yesterday.  
Today metrics are being indexed in an index from today.

But I see a lot of segments in my _old_ index (yesterday), and I don't know if Elasticsearch is going to merge that segments again sometime in the future.

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 13, 2020, 9:48pm UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/6 "2020-05-13T21:48:11Z")

</div>

Oh my bad! I misread your previous message!

Yes you can forcemerge.  
If you're using ILM you could even embed the forcemerge in a policy to do it automatically.

---

<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:** [May 14, 2020, 5:15am UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/7 "2020-05-14T05:15:07Z")

</div>

100 segments does not sound that much. Is this in any way causing problems?

---

<div class="post-metadata">

**Author:** ![Emanuel\_Velzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuel_velzi/32/66975_2.png) [@Emanuel\_Velzi](https://discuss.elastic.co/u/Emanuel_Velzi)\
**Post date:** [May 14, 2020, 11:41am UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/8 "2020-05-14T11:41:09Z")

</div>

Not really, but I would like to optimise the indices as much as possible, and I find that 1 segment per shard is the best for warm or cold indices...

I could execute a forcemerge, that's ok. But if not, should I expect that Elasticsearch by itself merge that segments sometime in the future? Or ES no longer works with that old indices anymore?

---

<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:** [May 14, 2020, 11:44am UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/9 "2020-05-14T11:44:57Z")

</div>

If you want to go to a single segment per shard you will need to manually forcemerge.

---

<div class="post-metadata">

**Author:** ![Emanuel\_Velzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuel_velzi/32/66975_2.png) [@Emanuel\_Velzi](https://discuss.elastic.co/u/Emanuel_Velzi)\
**Post date:** [May 14, 2020, 11:49am UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/10 "2020-05-14T11:49:16Z")

</div>

Ok.. thank guys!

---

<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:** [June 11, 2020, 11:49am UTC](https://discuss.elastic.co/t/where-is-the-merge-policy-defined/232496/11 "2020-06-11T11:49:28Z")

</div>

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