# Delete several documents in elastic with logstash?

**URL:** https://discuss.elastic.co/t/delete-several-documents-in-elastic-with-logstash/146555
**Category:** Logstash
**Created:** [August 29, 2018, 3:35pm UTC](https://discuss.elastic.co/t/delete-several-documents-in-elastic-with-logstash/146555 "2018-08-29T15:35:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nicolasl](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nicolasl](https://discuss.elastic.co/u/nicolasl)
#### Post date: [August 29, 2018, 3:35pm UTC](https://discuss.elastic.co/t/delete-several-documents-in-elastic-with-logstash/146555/1 "2018-08-29T15:35:37Z")

</div>

Hello,

I would like to delete multiple document with logstash in elasticsearch before sending the data to elastic. Why .. ?

For example, I ingest a file into elastic with logstash. On the next day, I receive an updated version of that file. Some of the data inserted the first day were update, some added and some removed.

So I would like to delete all previously ingested data between 2 date and then ingest the new data. I have to do so because if I only update the data, my removed data in the file will not be removed in elastic.

I can delete 1 document and only 1 using the action delete in my elastic output. As I would like to delete multiple documents so it does not work for me.

The only way I see is to use a ruby script in the filter part and use \_delete\_by\_query with curl but it is a bit killer. Maybe I missed a better way to do it ?

Or maybe with the http output pluging and the post method ?

Thanks.

---

<div class="post-metadata">

### Author: ![nicolasl](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nicolasl](https://discuss.elastic.co/u/nicolasl)
#### Post date: [August 30, 2018, 8:00am UTC](https://discuss.elastic.co/t/delete-several-documents-in-elastic-with-logstash/146555/2 "2018-08-30T08:00:58Z")

</div>

Ok I have found a way with the http output pluging and the post method :

```auto
http {
          url => "http://es-svc:25000/logstash-test-xml-data-mp/_delete_by_query"
          http_method => "post"
          format => "message"
          content_type => "application/json"
          message => '{"query":{"range":{"observationtimestart":{"gte":"%{ValidityStart}","lte":"%{ValidityStop}"}}}}'
        }

```

---

<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: [September 27, 2018, 8:01am UTC](https://discuss.elastic.co/t/delete-several-documents-in-elastic-with-logstash/146555/3 "2018-09-27T08:01:13Z")

</div>

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