# How to delete the record from elasticsearch if record has been deleted from source like oracle database

**URL:** <https://discuss.elastic.co/t/how-to-delete-the-record-from-elasticsearch-if-record-has-been-deleted-from-source-like-oracle-database/126435>\
**Category:** Logstash\
**Created:** [April 2, 2018, 1:57pm UTC](https://discuss.elastic.co/t/how-to-delete-the-record-from-elasticsearch-if-record-has-been-deleted-from-source-like-oracle-database/126435 "2018-04-02T13:57:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajitkaurav](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@ajitkaurav](https://discuss.elastic.co/u/ajitkaurav)\
**Post date:** [April 2, 2018, 1:57pm UTC](https://discuss.elastic.co/t/how-to-delete-the-record-from-elasticsearch-if-record-has-been-deleted-from-source-like-oracle-database/126435/1 "2018-04-02T13:57:21Z")

</div>

Hi guys

I am using logstash config file and get the data from oracle database .config detail given below . it works as expected but while I do delete the data from oracle database . but elasticsearch not deleting that record . i want remove that record if i have deleted record from oracle both should matched .

could me help me out.

input  
{  
jdbc {  
#Path to download jdbc deriver and add in class path  
jdbc\_driver\_library =\> "../jar/ojdbc6.jar"

# ORACLE Driver Class

jdbc\_driver\_class =\> "Java::oracle.jdbc.driver.OracleDriver"

# ORACLE database jdbc connection string , jdbc:oracle:thin:@hostname:PORT/SERVICE

jdbc\_connection\_string =\> "jdbc:oracle:thin:@hostname:1521/service"  
#The user and password to connect to database  
jdbc\_user =\> "username"  
jdbc\_password =\> "password"  
#Use when need to read password from file  
#jdbc\_password\_filepath =\> "/opt/app/password-path-location"  
jdbc\_paging\_enabled =\> "true"  
jdbc\_page\_size =\> "50000"  
#Configure Cron to How frequent want execute query in database  
schedule =\> "\*/15 \* \* \* \*"  
#Use below if query is big and want to store in separate file  
#statement\_filepath =\>"../query/remedy-tickets-details.sql"  
#Use for Inline query and if want to execute record after last run compare with value sql\_last\_value that can be numeric or timestamp  
statement =\> "select defect\_id,owned\_by,severity,status,summary,application,created\_by,creation\_date,modified\_by,modified\_date,assigned\_to from defect\_detail where defect\_id\>:sql\_last\_value order by defect\_id"  
#Below is configuration when want to use last run value  
clean\_run=\>true  
use\_column\_value =\> true  
tracking\_column =\> defect\_id  
#Logstash by default consider last\_sql\_value as numeric if it's timestamp configure specifically as timestamp  
#tracking\_column\_type =\> "timestamp"  
record\_last\_run =\> true  
#This file keep record of sql\_last\_value so that when next time query run can utilize last run values  
last\_run\_metadata\_path =\>"logstash\_jdbc\_last\_run\_t\_data.txt"  
#Define type of data from database  
type =\> "t-data"  
#Configure Timestamp according to database location  
#jdbc\_default\_timezone =\> "UTC"

}  
}  
filter  
{  
#To map your creation\_date column with elasticsearch @timestamp use below Date filter  
mutate  
{  
convert =\> ["creation\_date", "string"]  
}  
#Date pattern represent to date filter this creation\_date is on format "MM/dd/yyyy HH:mm"  
#and from timezone America/New\_York so that when store in elasticsearch in UTC will adjust accordingly

date {  
match =\> ["creation\_date","MM/dd/yyyy HH:mm"]  
timezone =\> "America/New\_York"  
}  
}  
output  
{  
#output to elasticsearch  
elasticsearch {  
index =\> "defect-data-%{+YYYY.MM}"  
hosts =\> ["elasticsearch-server:9200"]  
document\_type =\> "t-type"  
#Use document\_id in elasticsearch id you want to stop duplicate record in elasticsearch  
document\_id =\> "%{defect\_id}"  
}  
#Output to console  
stdout { codec =\> rubydebug}  
}

---

<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:** [April 30, 2018, 1:57pm UTC](https://discuss.elastic.co/t/how-to-delete-the-record-from-elasticsearch-if-record-has-been-deleted-from-source-like-oracle-database/126435/2 "2018-04-30T13:57:29Z")

</div>

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