0

I'm not sure how, but I'd like to continue on when this.tag_list is null

var mapFunc3 = function(){
   var tags = this.tag_list.split(',');
   for (i in tags) {
     emit(tags[i], 1);
   }
}

var reducFunc3 = function(key, values){
    var count = 0;
    for( i in values){
      count += values[i];
    }
    return count;
}

db.names.mapReduce(
    mapFunc3,
    reducFunc3,
    {out: "mr_3"}
)

The error I get is:

"errmsg" : "MapReduce internal error :: caused by :: TypeError: this.tag_list is null :\n@:2:5\n",
        "code" : 139,
        "codeName" : "JSInterpreterFailure"
} 
1
  • Make mapFunc3 as arrow function and try. Commented Oct 22, 2020 at 15:42

1 Answer 1

1

So instead of changing the JavaScript, I changed the Mongodb query so that it did not map any null items:

db.names.mapReduce(
mapFunc3,
reducFunc3,
{
out: {merge: "mr_3"},
query: {"tag_list": {$ne: null}}
}
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.