Changes between Version 16 and Version 17 of adeiSEARCH

Show
Ignore:
Author:
csa (IP: 141.52.232.84)
Timestamp:
09/14/09 04:15:24 (15 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • adeiSEARCH

    v16 v17  
    4343 The ''Search'' function of search engine may implement the search in arbitrary way. However, there is a standard procedure defined for search of textual data. It intended to standardize handling of search modifiers and simplify coding of new search engines for many standard cases. 
    4444The default implementation of engine ''Search'' function is using following procedure: 
    45  * ''GetList'' function is called to get complete associative list of available elements. In this list the key is an element identificator and value contains the presented above associative array describing the item. Besides the described standard properties, this array should contain  
     45 * ''!GetList'' function is called to get complete associative list of available elements. In this list the key is an element identificator and value contains the presented above associative array describing the item. Besides the described standard properties, this array should contain  
    4646Of course, the ''rating'' and ''certain'' fields are not set yet. So, we have the following list of properties: 
    4747  * ''title'' - title  
    5151  * ''name'' - record short name (used for matching) 
    5252  * arbitrary number of other properties used by custom matching functions 
    53  * Each item of the received string is matched against search terms using ''CheckString'' function. This function returns the match rating (''0'' means there is no match) 
     53 * Each item of the received string is matched against search terms using ''!CheckString'' function. This function returns the match rating (''0'' means there is no match) 
    5454 * The items for which the non-zero rating is returned are checked against filters and added to the search results 
    55  * Finally, the duplicating results are filtered using ''Accept'' function of ''SEARCHResults'' object. The comparisons between results are carried out using compare function returned by ''GetCmpFunction'' function of search engine. The default function just compares ''title'' members of the associative arrays describing compared items. 
     55 * Finally, the duplicating results are filtered using ''!Accept'' function of ''!SEARCHResults'' object. The comparisons between results are carried out using compare function returned by ''!GetCmpFunction'' function of search engine. The default function just compares ''title'' members of the associative arrays describing compared items. 
    5656 
    57 The default ''CheckString'' function is working in following way: 
    58  * The search string is split in phrases and for each phrase ''CheckPhrase'' function is called (see [wiki:adeiSEARCH/String] for splitting algorithm) 
    59  * Depending on the used module, the ''CheckPhrase'' function is expected to construct from the associative array a string value to match against search terms. The default behavior is to use ''name'' member of associative array. If the ''name'' member is empty or non-existing, the match fails. 
    60  * The constructed string value is passed to the ''CheckTitlePhrase'' function. 
    61  * ''CheckTitlePhrase'' function checks if passed string is fitting to the current search phrase and returns the rating.  
     57The default ''!CheckString'' function is working in following way: 
     58 * The search string is split in phrases and for each phrase ''!CheckPhrase'' function is called (see [wiki:adeiSEARCH/String] for splitting algorithm) 
     59 * Depending on the used module, the ''!CheckPhrase'' function is expected to construct from the associative array a string value to match against search terms. The default behavior is to use ''name'' member of associative array. If the ''name'' member is empty or non-existing, the match fails. 
     60 * The constructed string value is passed to the ''!CheckTitlePhrase'' function. 
     61 * ''!CheckTitlePhrase'' function checks if passed string is fitting to the current search phrase and returns the rating.  
    6262 * Finally the rating computed for all search phrases are reconciled in overall rating using rules described in the [wiki:adeiSEARCH/String] 
    6363 
    7272 * The class implementing ''!SEARCHEngine'' interface and extending ''!SEARCHEngine'' base class should be implemented 
    7373 * This class should provide a list of supported modules in the ''modules'' member of class. It is associative array where the key is module id and the value is module title. 
    74  * It should define either custom ''Search'' function or provide ''GetList'' function to be used in conjunction with the default approach described above. 
     74 * It should define either custom ''Search'' function or provide ''!GetList'' function to be used in conjunction with the default approach described above. 
    7575 * The implemented class should be stored under ''classes/search'' directory (the file name should be lower-cased class name with ''.php'' extension). 
    7676 * The search engine should be enabled in the configuration. A new element should be appended into the $SEARCH_ENGINE associative array. The key is a class name and the value is default initialization parameters. 
    7777 
    7878=== Standard Engine === 
    79 ''GetList'' function should return an array containing a descriptions of all all available items (through which we would search). This description is an associative array described in sections above. It should contain the following members: 
     79''!GetList'' function should return an array containing a descriptions of all all available items (through which we would search). This description is an associative array described in sections above. It should contain the following members: 
    8080 * ''title'' - the title used to describe record in the search results 
    8181 * ''description'' - the longer description of the record, HTML content is allowed 
    8383 * ''name'' or arbitrary number of other properties used by the search engine for record matching  
    8484 
    85 For example, the following array could be returned by the ''GetList'' function: 
     85For example, the following array could be returned by the ''!GetList'' function: 
    8686{{{ 
    8787 array( 
    9898}}} 
    9999 
    100 Of course, all other functions described in the ''Default Implementation'' section could be overridden as well. For example, if the engine is intended to support more than one search module, it needs to override ''CheckPhrase'' function. The default implementation constructs the match string just by taking ''name'' member of associative array. This string is, then, matched against search phrases. However, if multiple modules are used, for each module the algorithm for construction of match string should be specified. The ''CheckPhrase'' function in this case should construct a match string depending on the search module specified and pass it to the default ''CheckTitlePhrase'' function (or perform string matching by itself). 
     100Of course, all other functions described in the ''Default Implementation'' section could be overridden as well. For example, if the engine is intended to support more than one search module, it needs to override ''!CheckPhrase'' function. The default implementation constructs the match string just by taking ''name'' member of associative array. This string is, then, matched against search phrases. However, if multiple modules are used, for each module the algorithm for construction of match string should be specified. The ''!CheckPhrase'' function in this case should construct a match string depending on the search module specified and pass it to the default ''!CheckTitlePhrase'' function (or perform string matching by itself). 
    101101 
    102102=== Custom Engine === 
    103 The custom search engine needs to provide ''Search'' function. It should create the ''SEARCHResults'' object and fill it with results using ''Append'' function call. Then return the object or ''false'' if nothing is found.  
     103The custom search engine needs to provide ''!Search'' function. It should create the ''!SEARCHResults'' object and fill it with results using ''!Append'' function call. Then return the object or ''false'' if nothing is found.  
    104104Just a simple example: 
    105105{{{ 
    119119}}} 
    120120 
    121 The special search engines intended to return custom XHTML content should use following approach instead (the XHTML strings are passed to the ''Append'' function instead of the associative arrays describing found items): 
     121The special search engines intended to return custom XHTML content should use following approach instead (the XHTML strings are passed to the ''!Append'' function instead of the associative arrays describing found items): 
    122122{{{ 
    123123  $result = new SEARCHResults(NULL, $this, $module, ""); 
    134134}}} 
    135135 
    136 If such filter is found, the ''INTERVALSearchFilter'' object (defined in the  ''classes/search/intervalfilter.php'') is constructed. This object will get the filter value (''June 2005'') as a single parameter to its constructor. And it should implement a single function: ''FilterResult'' which should return ''true'' if the current record should be filtered out or ''false'' otherwise. The ''FilterResult'' receives two parameters: 
     136If such filter is found, the ''!INTERVALSearchFilter'' object (defined in the  ''classes/search/intervalfilter.php'') is constructed. This object will get the filter value (''June 2005'') as a single parameter to its constructor. And it should implement a single function: ''!FilterResult'' which should return ''true'' if the current record should be filtered out or ''false'' otherwise. The ''!FilterResult'' receives two parameters: 
    137137 * associative array with associative array describing the current item 
    138138 * current rating of match 
    139 Both these parameters can be altered by ''FilterResult'' function. 
     139Both these parameters can be altered by ''!FilterResult'' function. 
    140140 
    141 '''Example'''. Lets consider standard ''item'' search used in conjunction with ''interval'' filter. The search will provide multiple records describing found item (i.e. the associative array with information will contain standard properties: ''db_server'', ''db_name'', ''db_group'', and ''db_mask''). The ''interval'' filter is intended to limit the display interval. Therefore, when the ''FilterResult'' function is called, it will add the ''window'' property to the associative array limiting display window to ''June 2005''. 
     141'''Example'''. Lets consider standard ''item'' search used in conjunction with ''interval'' filter. The search will provide multiple records describing found item (i.e. the associative array with information will contain standard properties: ''db_server'', ''db_name'', ''db_group'', and ''db_mask''). The ''interval'' filter is intended to limit the display interval. Therefore, when the ''!FilterResult'' function is called, it will add the ''window'' property to the associative array limiting display window to ''June 2005''. 
    142142 
    143 If multiple filters are specified they are executed sequentially until any filter will not reject the current item by returning ''true'' from ''FilterResult'' function. 
     143If multiple filters are specified they are executed sequentially until any filter will not reject the current item by returning ''true'' from ''!FilterResult'' function. 
    144144  
    145145To implement a new filter it is necessary: 
    146146 * Choose a not used name, for example: ''site'' 
    147  * Implement ''SITESearchFilter'' class extending  ''BASESearchFilter'' (site is capitalized for class name) 
    148  * Implement ''FilterResult(&$info, &$rating)'' function which returns ''true'' if the value should be filtered out or ''false'' otherwise. The filter value is accessible using ''$this->value''. 
     147 * Implement ''!SITESearchFilter'' class extending  ''!BASESearchFilter'' (site is capitalized for class name) 
     148 * Implement ''!FilterResult(&$info, &$rating)'' function which returns ''true'' if the value should be filtered out or ''false'' otherwise. The filter value is accessible using ''$this->value''. 
    149149 * Place the implemented class in the ''classes/search/sitefilter.php'' (the lowercase filter name is used for the file name) 
    150150