# Delete and insert to elastic from logstash

**URL:** https://discuss.elastic.co/t/delete-and-insert-to-elastic-from-logstash/227399
**Category:** Logstash
**Created:** [April 9, 2020, 7:51pm UTC](https://discuss.elastic.co/t/delete-and-insert-to-elastic-from-logstash/227399 "2020-04-09T19:51:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![krishna\_bhargav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishna_bhargav/32/50877_2.png) [@krishna\_bhargav](https://discuss.elastic.co/u/krishna_bhargav)
#### Post date: [April 9, 2020, 7:51pm UTC](https://discuss.elastic.co/t/delete-and-insert-to-elastic-from-logstash/227399/1 "2020-04-09T19:51:31Z")

</div>

We have intraday updates to our records, so we need to delete and insert all child records.

logstash output : This is not deleting and insert , it's insert or update.

output {  
elasticsearch{  
hosts =\> ["xxxxxx"]  
index =\> "xxxxxx"  
document\_id =\> "xxxxxx"  
document\_type =\> "\_doc"  
user =\> xxxxx  
password =\> xxxxx  
action =\> "update"  
doc\_as\_upsert =\> "true"  
}  
}

sample:

initial data in elastic:

"keyInformation" : {  
"firmId" : "1",  
"entityType" : "HH",  
"entityId" : "1111",  
"lastUpdated" : "2020-04-09T16:08:17.181Z",  
"key" : "QA8\_COMMON\_101\_HH\_111"  
},  
"associatedAccounts" : [  
{  
"accountId" : "1",  
},  
{  
"accountId" : "2",  
},  
{  
"accountId" : "3",  
}  
]

after intraday load it should remove 1,2,3 and add 3,4,5

"associatedAccounts" : [  
{  
"accountId" : "4",  
},  
{  
"accountId" : "5",  
},  
{  
"accountId" : "6",  
}

we can't remove entire document because there are other child objects that may not have changed. so we have to update only specific list.

---

<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 7, 2020, 8:03pm UTC](https://discuss.elastic.co/t/delete-and-insert-to-elastic-from-logstash/227399/2 "2020-05-07T20:03:27Z")

</div>

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