Skip to content

Commit

Permalink
Example for issue #42
Browse files Browse the repository at this point in the history
Small example on how to use "script filters"
  • Loading branch information
richardwilly98 committed Dec 10, 2012
1 parent c33e19b commit 106de70
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/issues/42/01_create-river.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -XPUT "http://localhost:9200/_river/mongodb42/_meta" -d @mongodb-river-script-filters.json
8 changes: 8 additions & 0 deletions resources/issues/42/02_test-issue-42.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%MONGO_HOME%\bin\mongo < test-issue-42-import-document.js
pause
curl -XGET localhost:9200/mydb-42/_search?q=firstName:John42
pause
%MONGO_HOME%\bin\mongo < test-issue-42-update-document.js
pause
curl -XGET localhost:9200/mydb-42/_search?q=firstName:John42
pause
12 changes: 12 additions & 0 deletions resources/issues/42/mongodb-river-script-filters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "mongodb",
"mongodb": {
"db": "mydb",
"collection": "mycollec",
"script": "if( ctx.document.state == 'CLOSED' ) { ctx.deleted = true; }"
},
"index": {
"name": "mydb-42",
"type": "mycollec-42"
}
}
10 changes: 10 additions & 0 deletions resources/issues/42/test-issue-42-import-document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use mydb
var o =
{
"firstName": "John42",
"lastName": "Doe42",
"age": 34,
"state": "OPENED"
}

db.mycollec.save(o)
4 changes: 4 additions & 0 deletions resources/issues/42/test-issue-42-update-document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use mydb
var o = db.mycollec.findOne({"firstName": "John42", "lastName": "Doe42"})
o.state = 'CLOSED';
db.mycollec.save(o)

0 comments on commit 106de70

Please sign in to comment.