# Java Rest API does not allow ForceMergeAction for hot phase in LifeCyclePolicy

**URL:** <https://discuss.elastic.co/t/java-rest-api-does-not-allow-forcemergeaction-for-hot-phase-in-lifecyclepolicy/261258>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 15, 2021, 12:41pm UTC](https://discuss.elastic.co/t/java-rest-api-does-not-allow-forcemergeaction-for-hot-phase-in-lifecyclepolicy/261258 "2021-01-15T12:41:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ismarslomic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ismarslomic/32/63870_2.png) [@ismarslomic](https://discuss.elastic.co/u/ismarslomic)\
**Post date:** [January 15, 2021, 12:41pm UTC](https://discuss.elastic.co/t/java-rest-api-does-not-allow-forcemergeaction-for-hot-phase-in-lifecyclepolicy/261258/1 "2021-01-15T12:41:55Z")

</div>

While Elasticsearch REST API allows defining `forcemerge` action for hot phase, Java Rest API (v7.10.2) does not.

**This is allowed:**

```auto
PUT _ilm/policy/custom-ilm-policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "1d"
          },
          "forcemerge": {
            "max_num_segments": 1
          },
          "set_priority": {
            "priority": 200
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {
            "delete_searchable_snapshot": true
          }
        }
      }
    }
  }
}

```

**This is not allowed:**

```auto
Map<String, LifecycleAction> hotActions = new HashMap<>();

// Rollover action
hotActions.put(RolloverAction.NAME, new RolloverAction(
        new ByteSizeValue(50, ByteSizeUnit.GB), null, null));

// Forcemerge action
hotActions.put(ForceMergeAction.NAME, new ForceMergeAction(1));

phases.put("hot", new Phase("hot", TimeValue.ZERO, hotActions)); 

```

`IllegalArgumentException` is thrown with error `invalid action [forcemerge] defined in phase [hot]`. See [LifeCyclePolicy](https://github.com/elastic/elasticsearch/blob/7.10/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/LifecyclePolicy.java#L60)

---

<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:** [February 12, 2021, 12:41pm UTC](https://discuss.elastic.co/t/java-rest-api-does-not-allow-forcemergeaction-for-hot-phase-in-lifecyclepolicy/261258/2 "2021-02-12T12:41:55Z")

</div>

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