Fix inherited queries when accessing cursor by index

Now the document class will be set correctly in code like this::

    doc = cursor[3]