public function getResult($hydrationMode = null)
    {
        if ($hydrationMode) {
            $this->hydrationMode = $hydrationMode;
        }

        $classes = array();
        foreach (array_unique($this->entityClasses) as $entityClass) {
            $classes[] = $this->sm->getClassMetadata($entityClass);
        }

        $resultSet = $this->getSearchManager()->getClient()->search($this->query, $classes);

        // TODO: abstraction of support for different result sets
        if ($resultSet instanceof Elastica\ResultSet) {
            $this->count = $resultSet->getTotalHits();
            $this->facets = $resultSet->getFacets();
            $results = $resultSet->getResults();

        } else {
            $resultClass = get_class($resultSet);
            throw new DoctrineSearchException("Unexpected result set class '$resultClass'");
        }

        // Return results depending on hydration mode
        if ($this->hydrationMode == self::HYDRATE_BYPASS) {
            return $resultSet;
        } elseif ($this->hydrationMode == self::HYDRATE_INTERNAL) {
            return $this->sm->getUnitOfWork()->hydrateCollection($classes, $resultSet);
        }

        // Document ids are used to lookup dbms results
        $fn = function ($result) {
            return (string) $result->getId();
        };
        $ids = array_map($fn, $results);

        return $this->getHydrationQuery()
            ->setParameter($this->hydrationParameter, $ids ?: null)
            ->useResultCache($this->useResultCache, $this->cacheLifetime)
            ->getResult($this->hydrationMode);
    }