elasticsearch-river-mongodb icon indicating copy to clipboard operation
elasticsearch-river-mongodb copied to clipboard

Imprecise information on Wiki?

Open pierpaolocira opened this issue 10 years ago • 0 comments

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.

pierpaolocira avatar Apr 22 '15 10:04 pierpaolocira