PHP Class Frontend\Modules\Search\Engine\Model

Show file Open project: forkcms/forkcms Class Usage Examples

Public Methods

Method Description
buildTerm ( array $terms ) : array Build the search term
execSearch ( mixed $term, integer $limit = 20, integer $offset ) : array Execute actual search
getStartsWith ( string $term, string $language = '', integer $limit = 10 ) : array Get preview searches that start with .
getSynonyms ( string $term ) : array Get synonyms
getTotal ( string $term ) : integer Get total results
save ( array $item ) Save a search
search ( string $term, integer $limit = 20, integer $offset ) : array Search The actual search will be performed by the execSearch() method.
statusIndex ( string $module, array $otherIds, boolean $active = true ) Deactivate an index (no longer has to be searched)
validateSearch ( ) Validate searches: check everything that has been marked as 'inactive', if should still be inactive

Method Details

buildTerm() public static method

Build the search term
public static buildTerm ( array $terms ) : array
$terms array The string to build.
return array

execSearch() public static method

This function can be called with either a string as parameter (simple search) or an array (advanced search) Simple search: all search index fields will be searched for the given term Advanced search: only the given fields (keys in the array) will be matched to the corresponding values (corresponding values in the array)
public static execSearch ( mixed $term, integer $limit = 20, integer $offset ) : array
$term mixed The search term (simple search) or the fields to search for (advanced search - please note that the field names may not be consistent throughout several modules).
$limit integer The number of articles to get.
$offset integer The offset.
return array

getStartsWith() public static method

..
public static getStartsWith ( string $term, string $language = '', integer $limit = 10 ) : array
$term string The first letters of the term we're looking for.
$language string The language to search in.
$limit integer Limit result set.
return array

getSynonyms() public static method

Get synonyms
public static getSynonyms ( string $term ) : array
$term string The term to get synonyms for.
return array

getTotal() public static method

Note: please be aware that this is an approximate amount. It IS possible that this is not the exact amount of search results, since search results may vary in time (entries may not yet/no longer be shown) and we will not rebuild the entire search index on every search (would be a great performance killer and huge scalability loss) This function can be called with either a string as parameter (simple search) or an array (advanced search) Simple search: all search index fields will be searched for the given term Advanced search: only the given fields (keys in the array) will be matched to the corresponding values (corresponding values in the array)
public static getTotal ( string $term ) : integer
$term string The search term (simple search) or the fields to search for (advanced search - please note that the field names may not be consistent throughout several modules).
return integer

save() public static method

Save a search
public static save ( array $item )
$item array The data to store.

statusIndex() public static method

Deactivate an index (no longer has to be searched)
public static statusIndex ( string $module, array $otherIds, boolean $active = true )
$module string The module we're deleting an item from.
$otherIds array An array of other_id's for this module.
$active boolean Set the index to active?

validateSearch() public static method

Validate searches: check everything that has been marked as 'inactive', if should still be inactive
public static validateSearch ( )