src/CwpSearchEngine.php
public function search($keywords, $classes, $searchIndex, $limit = -1, $start = 0, $followSuggestions = false)
    {
        if (empty($keywords)) {
            return null;
        }

        try {
            // Begin search
            $result = $this->getResult($keywords, $classes, $searchIndex, $limit, $start, true);

            // Return results if we don't need to refine this any further
            if (!$followSuggestions || $result->hasResults() || !$result->getSuggestion()) {
                return $result;
            }

            // Perform new search with the suggested terms
            $suggested = $result->getSuggestion();
            $newResult = $this->getResult($suggested, $classes, $searchIndex, $limit, $start, false);
            $newResult->setOriginal($keywords);

            // Compare new results to the original query
            if ($newResult->hasResults()) {
                return $newResult;
            }

            return $result;
        } catch (Exception $e) {
            Injector::inst()->get(LoggerInterface::class)->warning($e);
        }
    }
public function search($keywords, $classes, $searchIndex, $limit = -1, $start = 0, $followSuggestions = false)
    {
        if (empty($keywords)) {
            return null;
        }

        try {
            // Begin search
            $result = $this->getResult($keywords, $classes, $searchIndex, $limit, $start, true);

            // Return results if we don't need to refine this any further
            if (!$followSuggestions || $result->hasResults() || !$result->getSuggestion()) {
                return $result;
            }

            // Perform new search with the suggested terms
            $suggested = $result->getSuggestion();
            $newResult = $this->getResult($suggested, $classes, $searchIndex, $limit, $start, false);
            $newResult->setOriginal($keywords);

            // Compare new results to the original query
            if ($newResult->hasResults()) {
                return $newResult;
            }

            return $result;
        } catch (Exception $e) {
            Injector::inst()->get(LoggerInterface::class)->warning($e);
        }
    }
public function search ( $ keywords , $ classes , $ searchIndex , $ limit = - 1 , $ start = 0 , $ followSuggestions = false ) { if ( empty ( $ keywords ) ) { return null ; } try { // Begin search $ result = $ this -> getResult ( $ keywords , $ classes , $ searchIndex , $ limit , $ start , true ) ; // Return results if we don't need to refine this any further if ( ! $ followSuggestions || $ result -> hasResults ( ) || ! $ result -> getSuggestion ( ) ) { return $ result ; } // Perform new search with the suggested terms $ suggested = $ result -> getSuggestion ( ) ; $ newResult = $ this -> getResult ( $ suggested , $ classes , $ searchIndex , $ limit , $ start , false ) ; $ newResult -> setOriginal ( $ keywords ) ; // Compare new results to the original query if ( $ newResult -> hasResults ( ) ) { return $ newResult ; } return $ result ; } catch ( Exception $ e ) { Injector :: inst ( ) -> get ( LoggerInterface :: class ) -> warning ( $ e ) ; } }
Get a CwpSearchResult for a given criterea

@param string $keywords
@param array $classes
@param SolrIndex $searchIndex
@param int $limit Max number of results for this page
@param int $start Skip this number of records
@param bool $followSuggestions True to enable suggested searches to be returned immediately
@return CwpSearchResult|null
Get a CwpSearchResult for a given criterea