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'''. |
---|
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. |
---|
| 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 | |
---|
| 101 | If 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 | |
---|
| 114 | Example: |
---|
| 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 | |
---|
| 128 | Besides ''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 |
---|