elasticsearch/elasticsearch-river-couchdb — Issue #7: CouchDB river plugin fails to delete documents in multi-type indices
Author: deverton
Created: 2012-01-05 04:45:25+00:00
State: open

We have a CouchDB river configured like this:

````json
{
"type" : "couchdb",
"couchdb" : {
"host" : "couchdb-host",
"port" : 5984,
"db" : "database",
"script" : "ctx._type = ctx.doc.type; if (ctx.doc.parent_id) ctx._parent = ctx.doc.parent_id"
}
}
````

The CouchDB database contains documents of various types which are mapped to Elasticsearch index types. The problem comes when one of those documents is deleted.

The changes feed doesn't seem to include the document data when a delete occurs so the script configured for the river can't decide the correct _type. Thus Elasticsearch ends up issuing a delete for a document that doesn't exist.

A workaround for this is to create one river per type with a filter function on the changes feed but this won't scale nicely if there's many document types.