Fix crash when querying with no indexes defined

This is a bit of a hacky fix. Ideally, we'd always have an index
defined over document ID, but it seems like an overhead to do so.
For now, therefore, fail.
Add tests for stopping enumeration over query results