# Deleting data

**URL:** <https://discuss.elastic.co/t/deleting-data/7367>\
**Category:** Elasticsearch\
**Created:** [April 17, 2012, 3:53pm UTC](https://discuss.elastic.co/t/deleting-data/7367 "2012-04-17T15:53:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![octomeow\_2](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@octomeow\_2](https://discuss.elastic.co/u/octomeow_2)\
**Post date:** [April 17, 2012, 3:53pm UTC](https://discuss.elastic.co/t/deleting-data/7367/1 "2012-04-17T15:53:43Z")

</div>

I have a very simple graylog2 set up using elasticsearch running  
happily

I want to know how to expire data, say logs older than 6 months. The  
delete  
query api seems to allow delete, but only by type or user, and not by  
age?

Could someone kindly point me in the right direction? Thanks.

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [April 17, 2012, 5:27pm UTC](https://discuss.elastic.co/t/deleting-data/7367/2 "2012-04-17T17:27:13Z")

</div>

On Apr 17, 8:53 am, octomeow [octom...@gmail.com](mailto:octom...@gmail.com) wrote:

> I want to know how to expire data, say logs older than 6 months. The  
> delete  
> query api seems to allow delete, but only by type or user, and not by  
> age?

You should be able to use any query to delete documents?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

---

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [April 17, 2012, 7:59pm UTC](https://discuss.elastic.co/t/deleting-data/7367/3 "2012-04-17T19:59:39Z")

</div>

As I remember you can set ttl to each document. You can find it on  
[elasticsearch.org](http://elasticsearch.org) pages, currently I can not check where exactly. I will  
check it tomorrow if you don't find it till then.

W dniu wtorek, 17 kwietnia 2012 użytkownik Eric Jain napisał:

> On Apr 17, 8:53 am, octomeow \<[octom...@gmail.com](mailto:octom...@gmail.com) \<javascript:;\>\> wrote:
> 
> > I want to know how to expire data, say logs older than 6 months. The  
> > delete  
> > query api seems to allow delete, but only by type or user, and not by  
> > age?
> 
> You should be able to use any query to delete documents?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)

---

<div class="post-metadata">

**Author:** ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)\
**Post date:** [April 18, 2012, 7:33am UTC](https://discuss.elastic.co/t/deleting-data/7367/4 "2012-04-18T07:33:01Z")

</div>

I think this is what you're talking about:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Apr 17, 10:59 pm, Marcin Dojwa [m.do...@livechatinc.com](mailto:m.do...@livechatinc.com) wrote:

> As I remember you can set ttl to each document. You can find it on  
> [elasticsearch.org](http://elasticsearch.org) pages, currently I can not check where exactly. I will  
> check it tomorrow if you don't find it till then.
> 
> W dniu wtorek, 17 kwietnia 2012 użytkownik Eric Jain napisał:
> 
> > On Apr 17, 8:53 am, octomeow \<[octom...@gmail.com](mailto:octom...@gmail.com) \<javascript:;\>\> wrote:
> > 
> > > I want to know how to expire data, say logs older than 6 months. The  
> > > delete  
> > > query api seems to allow delete, but only by type or user, and not by  
> > > age?
> 
> > You should be able to use any query to delete documents?
> 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)

---

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [April 18, 2012, 9:56am UTC](https://discuss.elastic.co/t/deleting-data/7367/5 "2012-04-18T09:56:00Z")

</div>

Exactly, this is what I was talking about.

W dniu 18 kwietnia 2012 09:33 użytkownik Radu Gheorghe \<  
[radu0gheorghe@gmail.com](mailto:radu0gheorghe@gmail.com)\> napisał:

> I think this is what you're talking about:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html)
> 
> On Apr 17, 10:59 pm, Marcin Dojwa [m.do...@livechatinc.com](mailto:m.do...@livechatinc.com) wrote:
> 
> > As I remember you can set ttl to each document. You can find it on  
> > [elasticsearch.org](http://elasticsearch.org) pages, currently I can not check where exactly. I will  
> > check it tomorrow if you don't find it till then.
> > 
> > W dniu wtorek, 17 kwietnia 2012 użytkownik Eric Jain napisał:
> > 
> > > On Apr 17, 8:53 am, octomeow \<[octom...@gmail.com](mailto:octom...@gmail.com) \<javascript:;\>\>  
> > > wrote:
> > > 
> > > > I want to know how to expire data, say logs older than 6 months. The  
> > > > delete  
> > > > query api seems to allow delete, but only by type or user, and not by  
> > > > age?
> > 
> > > You should be able to use any query to delete documents?
> > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)

---

<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:** [July 6, 2017, 3:32am UTC](https://discuss.elastic.co/t/deleting-data/7367/6 "2017-07-06T03:32:07Z")

</div>


