src/Kunstmaan/NodeSearchBundle/Search/NodeSearcher.php
protected function getPageBoosts()
    {
        $rescoreQueryBool = new BoolQuery();

        //Apply page type boosts
        $pageClasses = $this->em->getRepository('KunstmaanNodeBundle:Node')->findAllDistinctPageClasses();
        foreach ($pageClasses as $pageClass) {
            $page = new $pageClass['refEntityName']();

            if ($page instanceof SearchBoostInterface) {
                $elasticaQueryTypeBoost = new QueryString();
                $elasticaQueryTypeBoost
                    ->setBoost($page->getSearchBoost())
                    ->setDefaultField('page_class')
                    ->setQuery(addslashes($pageClass['refEntityName']));

                $rescoreQueryBool->addShould($elasticaQueryTypeBoost);
            }
        }

        //Apply page specific boosts
        $nodeSearches = $this->em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findAll();
        foreach ($nodeSearches as $nodeSearch) {
            $elasticaQueryNodeId = new QueryString();
            $elasticaQueryNodeId
                ->setBoost($nodeSearch->getBoost())
                ->setDefaultField('node_id')
                ->setQuery($nodeSearch->getNode()->getId());

            $rescoreQueryBool->addShould($elasticaQueryNodeId);
        }

        return $rescoreQueryBool;
    }
protected function getPageBoosts()
    {
        $rescoreQueryBool = new BoolQuery();

        //Apply page type boosts
        $pageClasses = $this->em->getRepository('KunstmaanNodeBundle:Node')->findAllDistinctPageClasses();
        foreach ($pageClasses as $pageClass) {
            $page = new $pageClass['refEntityName']();

            if ($page instanceof SearchBoostInterface) {
                $elasticaQueryTypeBoost = new QueryString();
                $elasticaQueryTypeBoost
                    ->setBoost($page->getSearchBoost())
                    ->setDefaultField('page_class')
                    ->setQuery(addslashes($pageClass['refEntityName']));

                $rescoreQueryBool->addShould($elasticaQueryTypeBoost);
            }
        }

        //Apply page specific boosts
        $nodeSearches = $this->em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findAll();
        foreach ($nodeSearches as $nodeSearch) {
            $elasticaQueryNodeId = new QueryString();
            $elasticaQueryNodeId
                ->setBoost($nodeSearch->getBoost())
                ->setDefaultField('node_id')
                ->setQuery($nodeSearch->getNode()->getId());

            $rescoreQueryBool->addShould($elasticaQueryNodeId);
        }

        return $rescoreQueryBool;
    }
protected function getPageBoosts ( ) { $ rescoreQueryBool = new BoolQuery ( ) ; //Apply page type boosts $ pageClasses = $ this -> em -> getRepository ( 'KunstmaanNodeBundle:Node' ) -> findAllDistinctPageClasses ( ) ; foreach ( $ pageClasses as $ pageClass ) { $ page = new $ pageClass [ 'refEntityName' ] ( ) ; if ( $ page instanceof SearchBoostInterface ) { $ elasticaQueryTypeBoost = new QueryString ( ) ; $ elasticaQueryTypeBoost -> setBoost ( $ page -> getSearchBoost ( ) ) -> setDefaultField ( 'page_class' ) -> setQuery ( addslashes ( $ pageClass [ 'refEntityName' ] ) ) ; $ rescoreQueryBool -> addShould ( $ elasticaQueryTypeBoost ) ; } } //Apply page specific boosts $ nodeSearches = $ this -> em -> getRepository ( 'KunstmaanNodeSearchBundle:NodeSearch' ) -> findAll ( ) ; foreach ( $ nodeSearches as $ nodeSearch ) { $ elasticaQueryNodeId = new QueryString ( ) ; $ elasticaQueryNodeId -> setBoost ( $ nodeSearch -> getBoost ( ) ) -> setDefaultField ( 'node_id' ) -> setQuery ( $ nodeSearch -> getNode ( ) -> getId ( ) ) ; $ rescoreQueryBool -> addShould ( $ elasticaQueryNodeId ) ; } return $ rescoreQueryBool ; }
Apply PageType specific and Page specific boosts

@return \Elastica\Query\BoolQuery
Apply PageType specific and Page specific boosts