elasticsearch-river-mongodb
elasticsearch-river-mongodb copied to clipboard
Imprecise information on Wiki?
Hi, I would like to suggest a modification to the main wiki page, because current information may lead to confusions. You wrote how to delete a document, or how to ignore a document... but I need both to correctly ignore (not index) a document depending by its status.
My needs was to not index documents where loadingStatus field was different than "completed"... but with your example:
- if you move "completed" to "uncompleted" it remains indexed
- if you delete an uncompleted document (indexed by previous point) it will remain
Seeking in the code (it seems there is no info about inside documentation) I found an "operation" object... so I rewritted Javascript to allow indexing only of "completed" documents, by the following code:
"script": "if (!ctx.document.loadingStatus || ctx.document.loadingStatus != \"completed\") {
if (ctx.operation==\"i\") {
ctx.ignore = true;
} else if (ctx.operation==\"u\") {
ctx.deleted = true;
}
}"
I think sharing this information it in the wiki can be useful for someone will meet my same problem.