# Deleting documents from couchdb doesn't delete it from ES index

**URL:** https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807
**Category:** Logstash
**Created:** [September 22, 2015, 7:33pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807 "2015-09-22T19:33:13Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![imad](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@imad](https://discuss.elastic.co/u/imad)
#### Post date: [September 22, 2015, 7:33pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/1 "2015-09-22T19:33:13Z")

</div>

I wondering if there is anything extra that I need do to delete a document from ES index when its deleted from my couchdb.

Here is how my config file looks like:

input {  
couchdb\_changes {  
db =\> "users"  
host =\> "127.0.0.1"  
port =\> 5984  
sequence\_path =\> "seq\_files\users\_couchdb\_seq"  
tags =\> ["users"]  
}  
}  
output {  
if "users" in [tags] {  
elasticsearch {  
document\_id =\> "%{[@metadata][\_id]}"  
host =\> "127.0.0.1"  
index =\> "users\_index"  
protocol =\> "http"  
host =\> '127.0.0.1'  
port =\> 9200   
}  
}  
}

Many thanks.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 22, 2015, 7:46pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/2 "2015-09-22T19:46:19Z")

</div>

What version of Logstash are you using?

---

<div class="post-metadata">

### Author: ![imad](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@imad](https://discuss.elastic.co/u/imad)
#### Post date: [September 23, 2015, 4:08pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/3 "2015-09-23T16:08:37Z")

</div>

I am using 1.5.4 version.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 23, 2015, 7:04pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/4 "2015-09-23T19:04:01Z")

</div>

I would run logstash with the `--debug` flag and capture the logs. I'd like to see them, if I could.

---

<div class="post-metadata">

### Author: ![imad](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@imad](https://discuss.elastic.co/u/imad)
#### Post date: [September 23, 2015, 8:03pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/5 "2015-09-23T20:03:08Z")

</div>

Actually whats happening is if data gets deleted by couchdb's normal delete call. Data seems to get deleted from index but the following entry still remains in the index corresponding to the item that got deleted in couchdb. How can I also have this deleted. Is there some sort of config setting to delete this as well.  
{  
"\_index": "user\_index",  
"\_type": "logs",  
"\_id": "b5a30ba6bcf908c1a3db884e68136d9e",  
"\_score": 1,  
"\_source": {  
"@version": "1",  
"@timestamp": "2015-09-23T19:40:01.172Z",  
"tags": [  
"sites"  
]  
}  
}

But the problem is when the whole couchDB is deleted, data in its respective index in ES is not deleted. I uploaded part of log at: [https://gist.github.com/imadulhaque/cd4cce8ea1356150ee75](https://gist.github.com/imadulhaque/cd4cce8ea1356150ee75). Please help.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 23, 2015, 8:22pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/6 "2015-09-23T20:22:21Z")

</div>

That is not the couchdb\_changes plugin then, but probably this issue: [https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/195](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/195)

---

<div class="post-metadata">

### Author: ![imad](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@imad](https://discuss.elastic.co/u/imad)
#### Post date: [September 25, 2015, 6:32pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/7 "2015-09-25T18:32:17Z")

</div>

@theuntergeek any idea when this fix will be in? We are close to release now, this can really put us in difficult situation if we don't have this fixed anytime soon.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 25, 2015, 7:28pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/8 "2015-09-25T19:28:55Z")

</div>

I can't say for sure. You could ask at that issue, and put some pressure there.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 25, 2015, 7:45pm UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/9 "2015-09-25T19:45:07Z")

</div>

As far as the data you're showing is concerned:

```
{
  "index": "userindex",
  "_type": "logs",
  "_id": "b5a30ba6bcf908c1a3db884e68136d9e",
  "_score": 1,
  "_source": {
    "@version": "1",
    "@timestamp": "2015-09-23T19:40:01.172Z",
    "tags": [
      "sites"
    ]
  }
}

```

The couchdb\_changes plugin creates an empty event on delete, and populates only the `@metadata` field with an action and an `_id`. Logstash requires that events have the `@timestamp` and `@version` fields, so the `run` method in the code has `decorate(event)`, which applies those fields. Having `tags => ['sites']` in your input puts that field there. I am making a presumption that these events are becoming documents in Elasticsearch because the output plugin is sending this data, instead of just the `DELETE` action and the associated document ID.

---

<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:27am UTC](https://discuss.elastic.co/t/deleting-documents-from-couchdb-doesnt-delete-it-from-es-index/29807/10 "2017-07-06T05:27:59Z")

</div>


