# How do I delete data from elasticsearch within a Range?

**URL:** <https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858>\
**Category:** Elasticsearch\
**Created:** [May 28, 2022, 1:48pm UTC](https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858 "2022-05-28T13:48:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dineshsekar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshsekar/32/106292_2.png) [@dineshsekar](https://discuss.elastic.co/u/dineshsekar)\
**Post date:** [May 28, 2022, 1:48pm UTC](https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858/1 "2022-05-28T13:48:31Z")

</div>

How do I delete data from Elasticsearch within a Range?  
I'm looking for an example.  
between 2022-01-22 and 2022-05-28

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [May 28, 2022, 2:36pm UTC](https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858/2 "2022-05-28T14:36:45Z")

</div>

Hi!

Read about [Delete by Query](https://discuss.elastic.co/t/delete-by-query-via-timestamp/134451/2). Try this:

```auto
POST teste/_delete_by_query
{
  "query": {
    "range": {
      "field_date": {
        "lt": "2022-05-06",
        "gt": "2022-05-01"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![dineshsekar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshsekar/32/106292_2.png) [@dineshsekar](https://discuss.elastic.co/u/dineshsekar)\
**Post date:** [May 30, 2022, 4:25am UTC](https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858/3 "2022-05-30T04:25:42Z")

</div>

[quote="RabBit\_BR, post:2, topic:305858"]  
teste

[quote]

I have questions.

1. Is it an index?  
(teste)

2. What does teste mean? Can you explain it?

3. Can I delete the data without an index?

I tried with index but I got an answer like this. can you help me?

 ![june](https://us1.discourse-cdn.com/elastic/original/3X/8/0/80bcdb08aa175767b840b244be82fea82c65311d.png)

POST /dome-plan-1.0.2022.05.30-00001/\_delete\_by\_query  
{  
"query": {  
"range": {  
"field\_date": {  
"lt": "2022-05-30",  
"gt": "2022-04-01"  
}  
}  
}  
}

{  
"took": 804,  
"timed\_out": false,  
"total": 0,  
"deleted": 0.  
"batches": 0.  
0, "version\_conflicts": 0.  
0, "noops": 0,  
"retries":  
0, "bulk": 0,  
"search": 0  
},  
0, "throttled\_millis": 0,  
"requests\_per\_second": -1.0%  
"throttled\_until\_millis" : 0,  
"failures":   
}

---

<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:** [June 27, 2022, 4:26am UTC](https://discuss.elastic.co/t/how-do-i-delete-data-from-elasticsearch-within-a-range/305858/4 "2022-06-27T04:26:28Z")

</div>

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