# Delete datas before insert

**URL:** <https://discuss.elastic.co/t/delete-datas-before-insert/26336>\
**Category:** Logstash\
**Created:** [July 27, 2015, 10:00am UTC](https://discuss.elastic.co/t/delete-datas-before-insert/26336 "2015-07-27T10:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vince059](https://avatars.discourse-cdn.com/v4/letter/v/76d3ee/32.png) [@Vince059](https://discuss.elastic.co/u/Vince059)\
**Post date:** [July 27, 2015, 10:00am UTC](https://discuss.elastic.co/t/delete-datas-before-insert/26336/1 "2015-07-27T10:00:37Z")

</div>

Hello !

I use logstash to save my CSV files in ElasticSearch.  
I need to delete my old datas before each treatment.

Example :

- a new CSV file is copied in my directory
- logstash delete items in elasticsearch with a query =\> { "query": { "match": { "DATA":"test" } } }
- logstash insert datas from CSV to elasticsearch

I can not use this [solution](https://discuss.elastic.co/t/replace-the-indexed-data-with-new-data/25442) because I need to delete ALL my datas with a query.

Can someone help me?

Thanks (sorry for my bad english ^^)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 27, 2015, 10:18pm UTC](https://discuss.elastic.co/t/delete-datas-before-insert/26336/2 "2015-07-27T22:18:39Z")

</div>

I don't think there is an clean way to do this with ES+LS, you may need to script something to delete data from ES and then call LS on the files.

---

<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, 5:33am UTC](https://discuss.elastic.co/t/delete-datas-before-insert/26336/3 "2017-07-06T05:33:44Z")

</div>


