MongoDB error 16052: exception: could not create cursor over...

Published on 2024-05-18 by Raul

When using map-reduce with sorting, I am getting this error:

uncaught exception: map reduce failed:{
"errmsg" : "exception: could not create cursor over .... for query : { col1: { $gt: new Date(1377982800000) }, col2: { $gt: 0.0 } } sort : { Time: 1.0 }",
"code" : 16052,
"ok" : 0
}

 

I searched for the error code, but could not find a fix. After a few hours of trial and error, I realised my problem: the column I was sorting on was not the key column of the map method. Turns out you can't use sort on map-reduce on column other than the key column.

Hope this helps.


Keep in touch


About

Hey there, I'm Raul, owner of CreativeCLR, a small consulting company.

Feel free to drop me any question you might have on this post using the comment section or the contact page.