Skip to content

Instantly share code, notes, and snippets.

@mzafer
Created May 8, 2013 17:25
Show Gist options
  • Save mzafer/5542043 to your computer and use it in GitHub Desktop.
Save mzafer/5542043 to your computer and use it in GitHub Desktop.
Extension of the scripts to test issue #64 (https://github.com/richardwilly98/elasticsearch-river-mongodb/tree/master/resources/issues/64) to add script for deletion of document is state is changed. The changes done are _02_mongodb-river-author.json -> Added "script" to delete the document if state == "INACTIVE" _03-import-document.js -> Added "…
{
"type": "mongodb",
"mongodb": {
"db": "mydb",
"collection": "authors",
"script": "if( ctx.document.state == 'INACTIVE' ) { ctx.deleted = true; }"
},
"index": {
"name": "authors",
"type": "author"
}
}
use mydb
var author =
{
"_id": "herge",
"name": "Herge",
"nationality": "Belge",
"state":"ACTIVE"
}
db.authors.save(author)
var book = {
"_parentId": "herge",
"name": "Titin au Congo",
"genre": "Bande dessinee",
"publisher": "Herge"
}
db.books.save(book)
use mydb
var o = db.authors.findOne({"name": "Herge"})
o.state = 'INACTIVE';
db.authors.save(o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment