# Life Cycle Policy with Filter rules?

**URL:** <https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [October 15, 2019, 2:46pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675 "2019-10-15T14:46:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Change\_Shell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/change_shell/32/47277_2.png) [@Change\_Shell](https://discuss.elastic.co/u/Change_Shell)\
**Post date:** [October 15, 2019, 2:46pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675/1 "2019-10-15T14:46:35Z")

</div>

I can set size and age, to remove documents. But I want to skip someone if has special field, for example

> Postpayment: true

never remove docs with field Postpayment, It`s possible?

---

<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:** [October 15, 2019, 4:04pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675/2 "2019-10-15T16:04:09Z")

</div>

Hi Change\_Shell,

This isn't currently possible, but you could do it manually with a delete-by-query. ILM doesn't currently have that functionality though.

---

<div class="post-metadata">

**Author:** ![Change\_Shell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/change_shell/32/47277_2.png) [@Change\_Shell](https://discuss.elastic.co/u/Change_Shell)\
**Post date:** [October 15, 2019, 4:26pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675/3 "2019-10-15T16:26:40Z")

</div>

You mean call delete\_by\_query in scheduler?  
with body something like that

> "must\_not": [  
> {  
> "term": {  
> "Postpayment" : true  
> }  
> }  
> ]

---

<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:** [October 15, 2019, 5:11pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675/4 "2019-10-15T17:11:39Z")

</div>

You couldn't call it from the internal ILM scheduling, but you could do it from a Cron job. You may want to configure an additional part of the query to not delete data from the newer indices (that is dependent on your retention needs)

---

<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:** [November 12, 2019, 5:11pm UTC](https://discuss.elastic.co/t/life-cycle-policy-with-filter-rules/203675/5 "2019-11-12T17:11:45Z")

</div>

Closed on November 12, 2019, 5:11pm UTC

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