# Index is starting policy again with shrink action

**URL:** <https://forum.opensearch.org/t/index-is-starting-policy-again-with-shrink-action/14179>\
**Category:** Index Management\
**Created:** [May 3, 2023, 5:37pm UTC](https://forum.opensearch.org/t/index-is-starting-policy-again-with-shrink-action/14179 "2023-05-03T17:37:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![slawkoPC](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@slawkoPC](https://forum.opensearch.org/u/slawkoPC)\
**Post date:** [May 3, 2023, 5:37pm UTC](https://forum.opensearch.org/t/index-is-starting-policy-again-with-shrink-action/14179/1 "2023-05-03T17:37:06Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.4.1

**Describe the issue** : My intention is to create a ISM policy that will shrink and index and continue it’s life in policy, but after the shrink action new renamed index is going back to the start of the policy (hot phase).

**Configuration** :

```auto
 "default_state": "hot",
    "states": [
        {
            "name": "hot",
            "actions": [
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "rollover": {
                        "min_doc_count": 5,
                        "min_index_age": "20m",
                        "min_primary_shard_size": "200mb"
                    }
                }
            ],
            "transitions": [
                {
                    "state_name": "cold",
                    "conditions": {
                        "min_index_age": "10m"
                    }
                }
            ]
        },
        {
            "name": "cold",
            "actions": [
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "allocation": {
                        "require": {
                            "data": "cold"
                        },
                        "include": {},
                        "exclude": {},
                        "wait_for": false
                    }
                },
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "shrink": {
                        "num_new_shards": 1,
                        "target_index_name_template": {
                            "source": "{{ctx.index}}_shrunken",
                            "lang": "mustache"
                        },
                        "force_unsafe": false
                    }
                }
            ],
            "transitions": [
                {
                    "state_name": "delete",
                    "conditions": {
                        "min_index_age": "40m"
                    }
                }
            ]
        },
        {
            "name": "delete",
            "actions": [
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "delete": {}
                }
            ],
            "transitions": []
        }
    ]

```

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [May 9, 2023, 7:47am UTC](https://forum.opensearch.org/t/index-is-starting-policy-again-with-shrink-action/14179/2 "2023-05-09T07:47:06Z")

</div>

I think the reason is that the new shrunken index has the same prefix with the original index, and the new shrunken index’s name hits the ISM template pattern defined in your policy, so the policy will be applied to the new shrunken index automatically. You can modify the `target_index_name_template.source` field in the shrink action of you policy to make the new index do not have same prefix with the original index and then no policy will be applied.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [July 8, 2023, 7:47am UTC](https://forum.opensearch.org/t/index-is-starting-policy-again-with-shrink-action/14179/3 "2023-07-08T07:47:40Z")

</div>

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