# Delete documents from elastic search if not exist in input

**URL:** https://discuss.elastic.co/t/delete-documents-from-elastic-search-if-not-exist-in-input/155154
**Category:** Elasticsearch
**Created:** [November 2, 2018, 11:11am UTC](https://discuss.elastic.co/t/delete-documents-from-elastic-search-if-not-exist-in-input/155154 "2018-11-02T11:11:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![marouprod](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@marouprod](https://discuss.elastic.co/u/marouprod)
#### Post date: [November 2, 2018, 11:11am UTC](https://discuss.elastic.co/t/delete-documents-from-elastic-search-if-not-exist-in-input/155154/1 "2018-11-02T11:11:30Z")

</div>

Hello friend,  
I have an elasticsearch database and i want to delete all documents if not exists in input statement? Can you help me please,

Thanks in advance

```
    input {jdbc {
jdbc_validate_connection => true
jdbc_connection_string => "jdbc:postgresql://xxxx:xxxx/xxxx"
jdbc_user => "xxxx"
jdbc_password => "xxxx"
jdbc_driver_library => "/usr/share/logstash/Drivers/postgres/postgresql-9.4.1212.jar"
jdbc_driver_class => "org.postgresql.Driver"
statement => "SELECT acso.usagers.id as id FROM acso.usagers WHERE acso.usagers.date_suppression is null"
tags => ["idUsagers"]}} filter {}output { elasticsearch {
action => delete
index => "usagers"
document_type => "atms"
doc_as_upsert => true
document_id => "%{id}"
hosts => "xxxxxx.example.org"}}
```

---

<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: [November 30, 2018, 12:17pm UTC](https://discuss.elastic.co/t/delete-documents-from-elastic-search-if-not-exist-in-input/155154/3 "2018-11-30T12:17:34Z")

</div>

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