src/services/ExtensibleSearchService.php
public function getSuggestions($term, $pageID, $limit = 5, $approved = true) {

		// Make sure the search matches the minimum autocomplete length.

		if($term && (strlen($term) > 2)) {

			// Make sure the current user has appropriate permission.

			$pageID = (int)$pageID;
			if(($page = ExtensibleSearchPage::get_by_id(ExtensibleSearchPage::class, $pageID)) && $page->canView()) {

				// Retrieve the search suggestions.

				$suggestions = ExtensibleSearchSuggestion::get()->filter(array(
					'Term:StartsWith' => $term,
					'Approved' => (int)$approved,
					'ExtensibleSearchPageID' => $pageID
				))->sort('Frequency', 'DESC')->limit($limit);

				// Make sure the search suggestions are unique.

				return $suggestions->column('Term');
			}
		}
		return array();
	}
public function getSuggestions($term, $pageID, $limit = 5, $approved = true) {

		// Make sure the search matches the minimum autocomplete length.

		if($term && (strlen($term) > 2)) {

			// Make sure the current user has appropriate permission.

			$pageID = (int)$pageID;
			if(($page = ExtensibleSearchPage::get_by_id(ExtensibleSearchPage::class, $pageID)) && $page->canView()) {

				// Retrieve the search suggestions.

				$suggestions = ExtensibleSearchSuggestion::get()->filter(array(
					'Term:StartsWith' => $term,
					'Approved' => (int)$approved,
					'ExtensibleSearchPageID' => $pageID
				))->sort('Frequency', 'DESC')->limit($limit);

				// Make sure the search suggestions are unique.

				return $suggestions->column('Term');
			}
		}
		return array();
	}
public function getSuggestions ( $ term , $ pageID , $ limit = 5 , $ approved = true ) { // Make sure the search matches the minimum autocomplete length. if ( $ term && ( strlen ( $ term ) > 2 ) ) { // Make sure the current user has appropriate permission. $ pageID = ( int ) $ pageID ; if ( ( $ page = ExtensibleSearchPage :: get_by_id ( ExtensibleSearchPage :: class , $ pageID ) ) && $ page -> canView ( ) ) { // Retrieve the search suggestions. $ suggestions = ExtensibleSearchSuggestion :: get ( ) -> filter ( array ( 'Term:StartsWith' => $ term , 'Approved' => ( int ) $ approved , 'ExtensibleSearchPageID' => $ pageID ) ) -> sort ( 'Frequency' , 'DESC' ) -> limit ( $ limit ) ; // Make sure the search suggestions are unique. return $ suggestions -> column ( 'Term' ) ; } } return array ( ) ; }
Retrieve the most relevant search suggestions.

@parameter <{SEARCH_TERM}> string
@parameter <{EXTENSIBLE_SEARCH_PAGE_ID}> integer
@parameter <{LIMIT}> integer
@parameter <{APPROVED_ONLY}> boolean
@return array
Retrieve the most relevant search suggestions .