protected function doIndex(Cursor $cursor, ProgressHelper $progress)
    {
        $queue = $this->getQueue();

        // the document manager need to be cleared from time to time so this counter keeps
        // track of that.

        $count = 0;
        $manager = $this->getDocumentManager();

        foreach ($cursor as $document) {
            $progress->advance();

            $job = new Job('ADD');

            $contentType = isset($document['contentType']) ? $document['contentType'] : '';

            $job->setOption('document.id', $contentType . '-' . $document['_id']);

            $job->setOption('document.data', json_encode(['id' => $document['_id']]));
            $job->setOption('document.class', $document['class']);
            $job->setOption('document.format', 'json');

            $queue->push($job);

            if (($count++ % 1000) == 0) {
                $manager->clear();
            }
        }
    }