# Multiple ILM Policies on same index: Which one applies?

**URL:** <https://discuss.elastic.co/t/multiple-ilm-policies-on-same-index-which-one-applies/240269>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [July 8, 2020, 6:12am UTC](https://discuss.elastic.co/t/multiple-ilm-policies-on-same-index-which-one-applies/240269 "2020-07-08T06:12:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keff](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@Keff](https://discuss.elastic.co/u/Keff)\
**Post date:** [July 8, 2020, 6:12am UTC](https://discuss.elastic.co/t/multiple-ilm-policies-on-same-index-which-one-applies/240269/1 "2020-07-08T06:12:22Z")

</div>

If I define multiple ILM Policies on patterns that match the same index, which one applies? Does the one with the lower "min\_age" apply or the one which was created first? Or anything else?

Example:  
If I now create the index "test-index" it is matched by both policies. Is it deleted after 1h or 2h?

```auto
        PUT _ilm/policy/ilm_1h
    {
        "policy": {
            "phases": {
                "hot": {
                    "min_age": "0ms",
                    "actions": {
                        "set_priority": {
                            "priority": 100
                        }
                    }
                },
                "delete": {
                    "min_age": "1h",
                    "actions": {
                        "delete": {}
                    }
                }
            }
        }
    }

    PUT _ilm/policy/ilm_2h
    {
        "policy": {
            "phases": {
                "hot": {
                    "min_age": "0ms",
                    "actions": {
                        "set_priority": {
                            "priority": 100
                        }
                    }
                },
                "delete": {
                    "min_age": "2h",
                    "actions": {
                        "delete": {}
                    }
                }
            }
        }
    }

    PUT _template/template_1h
    {
    	"index_patterns": ["test-*"],
    	"settings": {
    		"index.lifecycle.name": "ilm_1h"
    	}
    }

    PUT _template/template_2h
    {
    	"index_patterns": ["test-index"],
    	"settings": {
    		"index.lifecycle.name": "ilm_2h"
    	}
    }

```

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [July 8, 2020, 3:15pm UTC](https://discuss.elastic.co/t/multiple-ilm-policies-on-same-index-which-one-applies/240269/2 "2020-07-08T15:15:04Z")

</div>

That would depend on the order that the templates were applied. In order to make this deterministic, you'll need to add the `"order"` parameter in each template so that they can be explicitly merged in a particular order.

---

<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:** [August 5, 2020, 3:15pm UTC](https://discuss.elastic.co/t/multiple-ilm-policies-on-same-index-which-one-applies/240269/3 "2020-08-05T15:15:08Z")

</div>

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