It has turned out that the real problem was elsewhere. The cursor lost exception was caused by another process running in parallel which also used the database heavily and did complex computations with the data. When I had changed the cron time to avoid overlaps the problem went away.
I have still optimised my aggregation as aneroid suggested (combine all the match stages into one, add an _id => 0 field to the project stage and give the answers.data.value field a name), and it really improves the running time. I am now in the process of optimising the Ruby calculations, and it's much faster now.