# How to delete by query

**URL:** <https://discuss.elastic.co/t/how-to-delete-by-query/271170>\
**Category:** Elasticsearch\
**Created:** [April 25, 2021, 7:18am UTC](https://discuss.elastic.co/t/how-to-delete-by-query/271170 "2021-04-25T07:18:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Champion\_Xie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/champion_xie/32/71770_2.png) [@Champion\_Xie](https://discuss.elastic.co/u/Champion_Xie)\
**Post date:** [April 25, 2021, 7:18am UTC](https://discuss.elastic.co/t/how-to-delete-by-query/271170/1 "2021-04-25T07:18:01Z")

</div>

how to delete by query

current index\_name :logstash-2021.04.23  
actually Data entered the index of the current timestamp because of index definition error. How to delete contain 2021.04.22 in the index(logstash-2021.04.23)  
the data timestamp is 2021.04.22

in the index logstash-2021.04.23 contain content:

127.0.0.1 zh: 2001:dc8:ccff::2000:6702 - - [**22/Apr/2021** :00:23:08 +0800] "HEAD [无法访问此网站](http://www.bigcity.cn/index.html) HTTP/1.1" 200 0 "-" "bigip/11.5.4" "-"

need to delete contain "22/Apr/2021 "

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 25, 2021, 9:15am UTC](https://discuss.elastic.co/t/how-to-delete-by-query/271170/2 "2021-04-25T09:15:05Z")

</div>

Documentation is here: [Delete by query API | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html)

Make sure that you run a search before to make sure you are only getting the results you want to delete.

---

<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:** [May 23, 2021, 9:15am UTC](https://discuss.elastic.co/t/how-to-delete-by-query/271170/3 "2021-05-23T09:15:59Z")

</div>

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