Thank you for the response. It does generate the result required but it is very slow. The in operator is doing a collection scan of 7 million documents against the backbone array which has like 5 elements. some structures have hundreds of values. I thought I could replace the $in with a function and perform something like db.collection.find to speed it up, but from what I read db object isn’t accessible from function.
Anyway thanks for the help, if you know something about how to speed it up please do let me know