Back to the module list

The Full Text Search

The Full Text Search permit to found some data in a database based on a user query (like the search engines in the web).

Usage

$fts = new Domframework\Fts ();
$res = $fts->search ("\"ABC KLM\" XYZ");

The class definition

Class Domframework\Fts

Namespace Domframework

Description

 The Full Text Search
 Analyze the provided search text (like a search engine), and create the
 sql query to found the answer. It also allow to check if a sentence is valid
 against a searched text
 Manage the sentences (enclosed in quotes), or the standalone words,
 Manage the non wanted field (beginning by -),
 Do not search if the word is smaller than a parameter.
 Each sentence or word can be modified by external methods separately

Properties

public $minLength=3;
 The minimum length of a token to search

Methods

public function __construct ()
 The constructor check the availability of the MB module

public function callTokenSentence ( $callable)
 Set the method to call on tokens sentence only
 The method must return the token updated
 @param callable $callable The callable method
 @return $this

public function callTokenWord ( $callable)
 Set the method to call on tokens word only
 The method must return the token updated
 @param callable $callable The callable method
 @return $this

public function getQuery ()
 Construct the query based on the tokens.
 The tokens can be updated by methods so the query may be modified by the
 external methods
 @return string

public function getRegexes ()
 Get the regexes defined after the analyzer

public function getTokens ()
 Get the tokens store after the search

public function getTokensMin ()
 Get the tokens store after the search, without the too small ones

public function search ( $query)
 Explode the query text provided in $query, to be used to search in
 database, file...
 @param string $query The text to found in the database
 @return array The operator and the associated regex value to search

public function searchSQL ( $query, $dblayeroo, $fields)
 Search in SQL
 @param string $query The text to found in the database
 @param object $dblayeroo The dblayeroo object to query
 @param array|null $fields The fields in $dblayeroo to look for data. If
 null, look in all the fields defined in the dblayeroo object
 @return array The result of the query

public function searchString ( $line, $query)
 Return $line if the $query match against $line, or false if not
 @param string $line The line to examine
 @param string $query The query to apply on it
 @return string|false The $line if match, false