I am using Ruby and MongoDB in a project and I got today this Exception here:
Mongo::OperationFailure (too much data for sort() with no index):
The Problem was really that the searched field was not indexed. You can add an index like this:
That means the attribute “name” on the “products” document get indexed in asc order. That improved my search results enorm. But if the search results are to big, you will still get the same error.
I just solved the problem by limiting the search results. If you are using MongoID for ruby you can add this to your query:
That means you will just get the first 300 search results. In my case that is perfect.