richardwilly98 / elasticsearch-river-mongodb

MongoDB River Plugin for ElasticSearch
1.12k stars 215 forks source link

Imprecise information on Wiki? #520

Open pierpaolocira opened 9 years ago

pierpaolocira commented 9 years ago

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:

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.