MongoDB map/reduce counts

Posted by ibz on Stack Overflow See other posts from Stack Overflow or by ibz
Published on 2010-05-26T07:52:56Z Indexed on 2010/05/26 8:21 UTC
Read the original article Hit count: 246

Filed under:
|

The output from MongoDB's map/reduce includes something like 'counts': {'input': I, 'emit': E, 'output': O}. I thought I clearly understand what those mean, until I hit a weird case which I can't explain.

According to my understanding, counts.input is the number of rows that match the condition (as specified in query). If so, how is it possible that the following two queries have different results?

db.mycollection.find({MY_CONDITION}).count()

db.mycollection.mapReduce(SOME_MAP, SOME_REDUCE, {'query': {MY_CONDITION}}).counts.input

I thought the two should always give the same result, independent of the map and reduce functions, as long as the same condition is used.

© Stack Overflow or respective owner

Related posts about mongodb

Related posts about mapreduce