Changes between Version 9 and Version 10 of adeiSEARCH

Show
Ignore:
Author:
csa (IP: 217.112.40.22)
Timestamp:
09/11/09 19:50:47 (15 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • adeiSEARCH

    v9 v10  
    1717 
    1818'''II''': The global options are going next to the search type and specified in the square brackets. This options then passed to the search modules with the search string and handled by the module code. The following options are supported: 
    19  * ''='' - Exact match, for most modules this means what the search string is matched completely without splitting into the phrases 
    20  * ''w'' - Word match,  
    21  * ''~'' - Fuzzy match 
     19 * ''='' - Exact match, this means what the search string is matched completely without splitting into the phrases 
     20 * ''w'' - Word match, if not overridden by match modifiers, see below  
     21 * ''~'' - Fuzzy match, if not overridden by match modifiers, see below 
    2222 
    2323'''III''': Then the search string is follows. If the ''Exact match'' flag is not specified, it consists of the phrases. The phrase is 
    2727 
    2828This is an example of a search string consisting of 4 components: two words, one phrase, and a regular expression: 
    29 {{{word1 word2 "phrase 3" /regexp/}}} 
     29{{ 
     30{word1 word2 "phrase 3" /regexp/ 
     31}}} 
    3032 
    3133Before each phrase, a match modifier could be specified. The following match modifiers are supported 
    6365 
    6466== Default Implementation == 
    65 The following procedure is executed for each module: 
     67The search modules are implemented using [wiki:adeiClassSEARCHEngine SEARCHEngines]. Each SEARCHEngine could provide one or more search module. The !SEARCHEngines are placed in ''classes/search'' folder in ADEI source tree. They should implement a ''Search'' function which accepts four parameters (module, search string, search filter, global options) and returns the [wiki:adeiClassSEARCHResults SEARCHResults] object with results or ''false'' if nothing found. However, standard modules can reuse default ''Search'' function implemented in base class ''classes/searchengine.php''. The following procedure is exeuted in this case: 
    6668 * ''Search'' function of ''Search Engine'' is executed with four parameters: module, search string, search filter, global options. 
    67  * ''GetList'' function is called to get complete associative list of elements. In this list the key is element identificator and value contains an associative array with terms to check against the search terms 
    68  * ''CheckString'' function is called on each element of the list, the elements for which the non-zero value is returned are added to the search results 
     69 * ''GetList'' function is called to get complete associative list of elements. In this list the key is element identificator and value contains an associative array with terms to check against the search terms. Besides  
     70  * ''uid'' - record unique identificator if any (used for matching) 
     71  * ''name'' - record short name (used for matching) 
     72  * ''title'' - title to use to present this record in the results 
     73  * ''description'' - longer description (html content is allowed) 
     74  * ''props'' - an associative array containing [wiki:adeiDG standard ADEI properties] fully describing this record. Fro example, for found data item the props array will contain: ''db_server'', ''db_name'', ''db_group'', and ''db_mask'' properties. For found interval, it would be just property ''window''. 
     75 * ''CheckString'' function is called on each element of the list, the elements for which the non-zero rating is returned are checked against filters and added to the search results 
     76 * To prevent duplicating results, the ''SEARCHResults::Accept'' function is used. The results are compared using '''GetCmpFunction'''. 
    6977 
    7078The ''CheckString'' is working in following way: 
    7179 * The search string is splited in phrases and for each phrase ''CheckPhrase'' function is called. 
    72  * 
     80 * Depending on the used module, the ''CheckPhrase'' function is selecting  from the associative array describing record a single string value and passes it to the ''CheckTitlePhrase'' function. 
     81 * ''CheckTitlePhrase'' checks if passed string is fitting to the current search phrase and returns the rating. The matching is performed in one of 4 supported modes depending on the match modifiers and global options 
     82  * ''defualt'' - The beginning of any word should match search phrase. The '''word sinus cosinusfff''' matches the phrase '''sinus cosinus''', but '''xsinus cosinus''' - not. 
     83  * ''word match'' - The words should match completely. The '''word sinus cosinus fff''' matches, and '''sinus cosinusfff''' - not. 
     84  * ''fuzzy match'' - The words boundaries are not important and even '''xsinus cosinusx''' matches the '''sinus cosinus''' search phrase. 
     85  * ''regex match'' - In this mode the search phrase considered regular expression and this regular expression is matched against passed string 
     86 * Finally the rating computed for all search phrases are reconciled in overall rating using rules described in the section above. 
    7387 
    74  *  
    75 Filters are implemented as classes 
    76 == Providing New Search Engine == 
     88== Search Filters == 
     89The filters are used to reject part of the search results as well as to add/modify information associated with found record. The filters are specified at the search string as follows: 
     90{{{ 
     91   interval:June 2005 
     92}}} 
    7793 
     94If such filter is found, the ''INTERVALSearchFilter'' object (from ''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: 
     95 * associative array with information on current record 
     96 * a number between 0 and 1 with the rating of match 
     97Both these parameters can be altered by ''FilterResult'' function. 
    7898 
     99'''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''. 
     100 
     101If multiple filters are specified they executed sequentially until any filter will not reject the current record. 
     102  
     103== New Search Engine ==  
     104 * The search engine 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. 
     105 * It should define either special ''Search'' function or provide at least the ''GetList'' function to be used in conjunction with the approach described above. 
     106 
     107''GetList'' function should return array containing the records. Each record is represented by associative array with following members: 
     108 * ''title'' - the title used to describe record in the search results 
     109 * ''description'' - the longer description of the record, HTML content is allowed 
     110 * ''props'' - the associative array with standard ADEI properties describing the record 
     111 * ''certain'' - this option indicates what the search module is completely certain what it is this record what he user is actually looking for 
     112 * Arbitrary properties used by the search engine for record matching 
     113 
     114Example: 
     115{{{ 
     116 array( 
     117   array( 
     118     'title' => 'January 2005', 
     119     'props' => array( 
     120         'window' => "1104537600-1107216000" 
     121     ), 
     122     'description' => false, 
     123     'certain' => true 
     124  ) 
     125) 
     126}}} 
     127 
     128Besides ''GetList'' function it is highly desirable to provide ''CheckPhrase'' function which will check the record info against the search phrase and return the match rating, from ''0'' (not matched) to ''1'' (fully matched). The ''CheckPhrase'' function accepts the following parameters 
     129 * The associative array with information described above 
     130 * The phrase to match 
     131 * Type of match: ''SEARCH::WORD_MATCH'', ''SEARCH::FUZZY_MATCH'', ''SEARCH::REGEX_MATCH'', ''false'' (default) 
     132 * The search module 
     133 * The global options 
    79134 
    80135== INTERVALSearch Engine == 
    81136'''Provided Modules''': 
    82  * ''interval'' -  
     137 * ''interval'' - Tries to parse the time interval from textual representation given in search string. The only property ''window'' is returned with interval of UNIX timestmaps. 
    83138 
    84139'''Supported Filters''': 
    85  * ''interval''' 
     140 * ''interval''' - allows to find intersection of two intervals 
    86141 
    87142== ITEMSearch Engine == 
    95150 * ''control_group'' - Searches control groups by name 
    96151 
     152'''Supported Filters''': 
     153 * ''interval''' - adds window property to the items specification 
     154 
    97155== PROXYSearch Engine == 
    98156'''Provided Modules''': 
    99  * ''proxy'' - 
     157 * ''proxy'' -  
    100158 
    101159'''Supported Filters''':