Version 8 (modified by csa, 15 years ago)
--

SEARCH SubSystem

ADEI has a modular search subsystem. The search capabilities are provided by the search engines which providing one-or-more search modules. Besides the search term, the search string may specify the search modules to perform search and number of limits to filter results. The module parameters could be specified along with the modules.

Format of search string

The search string consists of four components:

  • The first component defines type of the search. Examples are item search, channel value search, datetime search.
  • Second component provides some options. For example, demands exact or fuzzy match
  • Third and fourth components are type-dependent and containing search string and additional limits

I: The format is as follows:

[type/module specification] [global flags] <search string> [limits]

Everything besides search string is optional. By default if the type is not specified, the search string is analyzed. Analysis routine guesses the type of search and executes a default set of modules for this type. The default behavior is to search for channel and group names. See String Analysis section for details.

The search type is specified in the curly brackets in the beginning of the search string. The search module available in the classes/search should be indicated (name of the class should be specified). Optional options for the class constructor could be indicated as well. If multiple modules are specified, the multiple searches are performed sequentially. The following format is expected:

{module_name(opt1=value1,opt=value2), another_module(...)}

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:

  • = - Exact match, for most modules this means what the search string is matched completely without splitting into the phrases
  • w - Word match,
  • ~ - Fuzzy match

III: Then the search string is follows. If the Exact match flag is not specified, it consists of the phrases. The phrase is

  • words consisting of alphanumeric symbols, dash and underscore symbols (-,_)
  • multiple words enclosed in singular or double quotes('")
  • regular expressions enclosed in / from both ends

This is an example of a search string consisting of 4 components: two words, one phrase, and a regular expression: word1 word2 "phrase 3" /regexp/

Before each phrase, a match modifier could be specified. The following match modifiers are supported

  • if no modifier is specified, the phrases starting from search term will be matched
  • = - full match, the whole words are matched
  • ~ - fuzzy match, any part of a word could be matched

Please consider following example to understand the meaning of match modifiers. By default if a search for sin is performed the words sin and sinus will be matched, but cosinus - not. However, if a fuzzy search is given (~sin), the cosinus will be matched as well. On other hand if a full match is required (=sin), only sin will be matched. Both sinus and cosinus will be rejected.

The match of each phrase against data records produces ratings from 0 to 1 indicating match quality. The value 0 means what the record is not matched and value 1 indicates a full match. If several phrases are listed in search string, the ratings of each phrase match are multiplied to produce overall rating. For example, if phrase1 matched with rating 0.70, phrase2 matched with rating 0.30 and word3 is fully matched, the overall rating would be: 0.21 = 0.70 * 0.30 * 1.

Rating computation could be altered using unary and binary operations. Lets assume what [word] is a rating of word, then the ratings of these operations are computed as follows:

  • ! word - The resulting rating would be 1 - [word]
  • + word - The rating below 1 will be cat to 0
  • - word - All non-zero ratings will be cut to zero, and zero rating will be replaced with 1
  • (word1|word2) - The maximal rating amongst [word1] and [word2]

IV: On-or-more limits can be set in the last part of the search string. The following format is expected

 limit_name:limit_value another_limit:another_limit_value

The limits handling is completely module specific.

Default Implementation

The following procedure is executed for each module:

  • Search function of Search Engine is executed with four parameters: module, search string, search filter, global options.
  • 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
  • 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

The CheckString? is working in following way:

  • The search string is splited in phrases and for each phrase CheckPhrase? function is called. *

Filters are implemented as classes

Providing New Search Engine

INTERVALSearch Engine

Provided Modules:

  • interval -

Supported Filters:

  • interval

ITEMSearch Engine

Provided Modules:

  • channel - Searches items by uid only
  • item - Searches items by uid and name
  • group - Searches groups by name
  • mask - Searches masks by name
  • control - Searches controls by uid only
  • control_item - Searches controls by uid and name
  • control_group - Searches control groups by name

PROXYSearch Engine

Provided Modules:

  • proxy -

Supported Filters:

  • interval

String Analysis