public function indexSearch($searchText, $maxResults)
    {
        // split the phrase into words
        $words = SearchAnalyser::analyse($searchText);
        if (!$words) {
            return [];
        }

        $query = $this->_em->createQueryBuilder()
            ->select('o')
            ->from($this->_entityName, 'o')
            ->setMaxResults($maxResults);

        $parameters = [];
        foreach ($words as $k => $word) {
            $subquery = $this->_em->createQueryBuilder()
                ->select("i$k.keyword")
                ->from($this->getSearchIndexClass(), "i$k")
                ->where("i$k.object = o")
                ->andWhere("i$k.keyword ILIKE :search$k");
            $query->andWhere($query->expr()->exists($subquery->getDql()));
            $parameters["search$k"] = '%' . $word . '%';
        }
        $query->setParameters($parameters);

        $results = $query->getQuery()->execute();

        return $results;
    }
public function indexSearch($searchText, $maxResults)
    {
        // split the phrase into words
        $words = SearchAnalyser::analyse($searchText);
        if (!$words) {
            return [];
        }

        $query = $this->_em->createQueryBuilder()
            ->select('o')
            ->from($this->_entityName, 'o')
            ->setMaxResults($maxResults);

        $parameters = [];
        foreach ($words as $k => $word) {
            $subquery = $this->_em->createQueryBuilder()
                ->select("i$k.keyword")
                ->from($this->getSearchIndexClass(), "i$k")
                ->where("i$k.object = o")
                ->andWhere("i$k.keyword ILIKE :search$k");
            $query->andWhere($query->expr()->exists($subquery->getDql()));
            $parameters["search$k"] = '%' . $word . '%';
        }
        $query->setParameters($parameters);

        $results = $query->getQuery()->execute();

        return $results;
    }
public function indexSearch ( $ searchText , $ maxResults ) { // split the phrase into words $ words = SearchAnalyser :: analyse ( $ searchText ) ; if ( ! $ words ) { return [ ] ; } $ query = $ this -> _em -> createQueryBuilder ( ) -> select ( 'o' ) -> from ( $ this -> _entityName , 'o' ) -> setMaxResults ( $ maxResults ) ; $ parameters = [ ] ; foreach ( $ words as $ k => $ word ) { $ subquery = $ this -> _em -> createQueryBuilder ( ) -> select ( "i$k.keyword" ) -> from ( $ this -> getSearchIndexClass ( ) , "i$k" ) -> where ( "i$k.object = o" ) -> andWhere ( "i$k.keyword ILIKE :search$k" ) ; $ query -> andWhere ( $ query -> expr ( ) -> exists ( $ subquery -> getDql ( ) ) ) ; $ parameters [ "search$k" ] = '%' . $ word . '%' ; } $ query -> setParameters ( $ parameters ) ; $ results = $ query -> getQuery ( ) -> execute ( ) ; return $ results ; }
Find the entities that have the appropriate keywords in their searchIndex.

@param string $searchText
@param int    $maxResults

@return Collection found entities
Find the entities that have the appropriate keywords in their searchIndex .