public function convert(AbstractPaginationQuery $filter, ArrayAccess $response)
    {
        $entities = [];
        $ids = [];
        $return = [];

        if (!isset($response['response'])
            || !isset($response['response']['docs'])
            || !is_array($response['response']['docs'])) {
            throw new InvalidArgumentException('invalid response');
        }
        
        foreach ($response['response']['docs'] as $doc) {
            $ids[] = $doc->id;
        }

        // fetch entities with given IDs
        $repository = $this->repositories->get($filter->getRepositoryName());
        $qb = $repository->createQueryBuilder() /* @var $repository \Core\Repository\AbstractRepository */
            ->field('id')
            ->in($ids);
        $result = $qb->getQuery()->execute();
        
        foreach ($result as $document) {
            $entities[$document->getId()] = $document;
        }
        
        // iterate over Solr response to preserve sorting
        foreach ($response['response']['docs'] as $doc) {
            $entity = isset($entities[$doc->id]) ? $entities[$doc->id] : $repository->create();
            $return[] = $filter->proxyFactory($entity, $doc);
        }
        
        return $return;
    }